0001    // TCPSocket.swift
0002    //
0003    // The MIT License (MIT)
0004    //
0005    // Copyright (c) 2015 Zewo
0006    //
0007    // Permission is hereby granted, free of charge, to any person obtaining a copy
0008    // of this software and associated documentation files (the "Software"), to deal
0009    // in the Software without restriction, including without limitation the rights
0010    // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0011    // copies of the Software, and to permit persons to whom the Software is
0012    // furnished to do so, subject to the following conditions:
0013    //
0014    // The above copyright notice and this permission notice shall be included in all
0015    // copies or substantial portions of the Software.
0016    //
0017    // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0018    // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0019    // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0020    // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0021    // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0022    // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0023    // SOFTWARE.
0024    
0025    import CLibvenice
0026    
0027    public class TCPSocket
TCPClientSocket.swift:28
public final class TCPClientSocket: TCPSocket {
TCPServerSocket.swift:28
public final class TCPServerSocket: TCPSocket {
{ 0028 var socket
TCPSocket.swift:32
        return Int(tcpport(socket))
TCPSocket.swift:36
        self.socket = socket
TCPSocket.swift:41
        if !closed && socket != nil {
TCPSocket.swift:42
            tcpclose(socket)
TCPSocket.swift:68
        tcpclose(socket)
: tcpsock 0029 public private(set) var closed
TCPSocket.swift:41
        if !closed && socket != nil {
TCPSocket.swift:47
        if !closed {
TCPSocket.swift:53
        closed = false
TCPSocket.swift:58
        closed = true
TCPSocket.swift:63
        if closed {
TCPSocket.swift:67
        closed = true
TCPSocket.swift:73
        if closed {
TCPStream.swift:43
        return socket.closed
= false 0030 0031 public var port
TCPStream.swift:39
        self.metadata["port"] = socket.port
: Int { 0032 return Int(tcpport(socket)) 0033 } 0034 0035 init
TCPClientSocket.swift:30
        try super.init(socket: socket)
(socket: tcpsock) throws { 0036 self.socket = socket 0037 try TCPError.assertNoError() 0038 } 0039 0040 deinit { 0041 if !closed && socket != nil { 0042 tcpclose(socket) 0043 } 0044 } 0045 0046 func attach(fileDescriptor: FileDescriptor, isServer: Bool) throws { 0047 if !closed { 0048 close() 0049 } 0050 0051 socket = tcpattach(fileDescriptor, isServer ? 1 : 0) 0052 try TCPError.assertNoError() 0053 closed = false 0054 } 0055 0056 public func detach() throws -> FileDescriptor { 0057 try assertNotClosed() 0058 closed = true 0059 return tcpdetach(socket) 0060 } 0061 0062 public func close
TCPSocket.swift:48
            close()
TCPStream.swift:80
        return socket.close()
() -> Bool { 0063 if closed { 0064 return false 0065 } 0066 0067 closed = true 0068 tcpclose(socket) 0069 return true 0070 } 0071 0072 func assertNotClosed
TCPClientSocket.swift:46
        try assertNotClosed()
TCPClientSocket.swift:60
        try assertNotClosed()
TCPClientSocket.swift:66
        try assertNotClosed()
TCPClientSocket.swift:78
        try assertNotClosed()
TCPClientSocket.swift:98
        try assertNotClosed()
TCPServerSocket.swift:38
        try assertNotClosed()
TCPSocket.swift:57
        try assertNotClosed()
() throws { 0073 if closed { 0074 throw TCPError.closedSocketError 0075 } 0076 } 0077 }