TCPConnection
public final class TCPConnection : TCPBase
A TCP Connection
-
Create a new connection on a network interface
Declaration
Swift
public init(interface: NetworkInterface)
Parameters
interface
-
This handler is called once new data is available. Once the data has been processed by the application
completionHandler()
must be called to request more data To avoid memory leaks. This handler will be set tonil
once the connection has been closedDeclaration
Swift
public var recvHandler: ((_ data: Data, _ completionHandler: @escaping () -> Void) -> Void)?
-
Start dispatching events of the connection/listener and set the queue to deliver the events on.
Declaration
Swift
public func start(queue: DispatchQueue)
Parameters
queue
The queue to dispatch the events on
-
Open a connection
Throws
LwIP errorDeclaration
Swift
public func connect(address: IP4Address, port: UInt16) throws
Parameters
address
Destination address
port
Destination Port
-
Close the connection immediately
Declaration
Swift
public func forceClose()
-
Close the connection
Declaration
Swift
override public func close()
-
Send new data
Throws
LwIP errorDeclaration
Swift
public func write(data: Data, completion: @escaping () -> Void) throws
Parameters
data
completion
This hanlder will be called once more data can be processed by the stack