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
  • isDisconnected Default implementation

    If the socket is disconnected.

    Default Implementation

    If the socket is disconnected.

    Declaration

    Swift

    var isDisconnected: Bool
  • typeName Default implementation

    The type of the socket.

    Default Implementation

    Undocumented

    Declaration

    Swift

    var typeName: String
  • readStatusDescription Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    public protocol SocketProtocol: class
  • writeStatusDescription Default implementation

    Undocumented

    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

    data

    Data to send.

  • Disconnect the socket elegantly.

    Declaration

    Swift

    func disconnect(becauseOf error: Error?)
  • Disconnect the socket immediately.

    Declaration

    Swift

    func forceDisconnect(becauseOf error: Error?)