SocketProtocol
public protocol SocketProtocol: class
Protocol for socket with various functions.
Any concrete implementation does not need to be thread-safe.
-
The underlying TCP socket transmitting data.
Declaration
Swift
var socket: RawTCPSocketProtocol! -
The delegate instance.
Declaration
Swift
weak var delegate: SocketDelegate? -
The current connection status of the socket.
Declaration
Swift
var status: SocketStatus -
isDisconnectedDefault implementationIf the socket is disconnected.
Default Implementation
If the socket is disconnected.
Declaration
Swift
var isDisconnected: Bool -
typeNameDefault implementationThe type of the socket.
Default Implementation
Undocumented
Declaration
Swift
var typeName: String -
readStatusDescriptionDefault implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
public protocol SocketProtocol: class -
writeStatusDescriptionDefault implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
public protocol SocketProtocol: class -
Read data from the socket.
Warning
This should only be called after the last read is finished, i.e.,delegate?.didReadData()is called.Declaration
Swift
func readData() -
Send data to remote.
Warning
This should only be called after the last write is finished, i.e.,delegate?.didWriteData()is called.Declaration
Swift
func write(data: Data)Parameters
dataData to send.
-
Disconnect the socket elegantly.
Declaration
Swift
func disconnect(becauseOf error: Error?) -
Disconnect the socket immediately.
Declaration
Swift
func forceDisconnect(becauseOf error: Error?)
View on GitHub
SocketProtocol Protocol Reference