TSTCPSocket

public final class TSTCPSocket

The TCP socket class.

Note

Unless one of socketDidReset(_:), socketDidAbort(_:) or socketDidClose(_:) delegation methods is called, please do close()the socket actively and wait for socketDidClose(_:) before releasing it.

Note

This class is NOT thread-safe, make sure every method call is on the same dispatch queue as TSIPStack.
  • The source IPv4 address.

    Declaration

    Swift

    public let sourceAddress: in_addr
  • The destination IPv4 address

    Declaration

    Swift

    public let destinationAddress: in_addr
  • The source port.

    Declaration

    Swift

    public let sourcePort: UInt16
  • The destination port.

    Declaration

    Swift

    public let destinationPort: UInt16
  • Whether the socket is connected (we can receive and send data).

    Declaration

    Swift

    public var isConnected: Bool { get }
  • The delegate that handles various TCP events.

    Warning

    This should be set immediately when developer gets an instance of TSTCPSocket from didAcceptTCPSocket(_:) on the same thread that calls it. Simply say, just set it when you get an instance of TSTCPSocket.

    Declaration

    Swift

    public weak var delegate: TSTCPSocketDelegate?
  • Send data to local rx side.

    Declaration

    Swift

    public func writeData(_ data: Data)

    Parameters

    data

    The data to send.

  • Close the socket. The socket should not be read or write again.

    Declaration

    Swift

    public func close()
  • Reset the socket. The socket should not be read or write again.

    Declaration

    Swift

    public func reset()