SwiftDSSocketDelegate

@objc public protocol SwiftDSSocketDelegate

delegate methods for each operation

  • delegate method called after reading data from socket

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didRead data: Data, tag: Int)

    Parameters

    sock

    SwiftDSSocket instance

    data

    data read from stream

    tag

    a tag to mark this read operation

  • delegate method called after reading partial data for specified data length from socket which allows users to know the progress of transfer

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didPartialRead totalCount: Int, tag: Int)

    Parameters

    sock

    SwiftDSSocket instance

    totalCount

    number of bytes read

    tag

    a tag to mark this read operation

  • delegate method called after reading data from socket

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didWrite tag: Int)

    Parameters

    sock

    SwiftDSSocket instance

    tag

    a tag to mark this write operation

  • delegate method called after writing partial data for specified data length to socket which allows users to know the progress of transfer

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didPartialWrite totalCount: Int, tag: Int)

    Parameters

    sock

    SwiftDSSocket instance

    totalCount

    number of bytes read

    tag

    a tag to mark this write operation

  • delegate method called after closing connection

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didCloseConnection error: SwiftDSSocket.SocketError?)

    Parameters

    sock

    SwiftDSSocket instance

    error

    SocketError indicates the reason why it gets closed

  • delegate method called after the connection to destination is established

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didConnectToHost host: String, port: UInt16)

    Parameters

    sock

    SwiftDSSocket instance

    host

    host address in String

    port

    port number in UInt16

  • delegate method called after an incoming connection is accepted

    Declaration

    Swift

    @objc optional func socket(sock: SwiftDSSocket, didAcceptNewSocket newSocket: SwiftDSSocket)

    Parameters

    sock

    SwiftDSSocket instance

    newSocket

    SwiftDSSocket instance for peer socket