TipInterface

public struct TipInterface: InterfaceAccess

This class implements the InterfaceAccess protocol for the POSIX TCP/IP socket interface.

  • An id that can be used for logging purposes and will differentiate between interfaces on a temporary basis.

    It should be guaranteed that no two interfaces with the same logId are active at the same time.

    Declaration

    Swift

    public var logId: Int32
  • The socket for this connection.

    Declaration

    Swift

    public private(set) var socket: Int32?
  • Returns true if the connection is still usable.

    Note

    Even if ‘true’ is returned it is still possible that the next attempt to use the interface will immediately result in a termination of the connection. For example if the peer has already closed its side of the connection.

    Declaration

    Swift

    public var isValid: Bool
  • Creates a new interface.

    Declaration

    Swift

    public init(_ socket: Int32)

    Parameters

    socket

    The socket to use for this interface.

  • Closes this end of a connection.

    Declaration

    Swift

    public mutating func close()
  • Transfers the data via the socket to the peer. This operation returns when the data has been accepted by the POSIX layer, i.e. the physical transfer may still be ongoing.

    Declaration

    Swift

    public func transfer(
            buffer: UnsafeBufferPointer<UInt8>,
            timeout: TimeInterval?,
            callback: TransmitterProtocol? = nil,
            progress: TransmitterProgressMonitor? = nil) -> TransferResult?

    Parameters

    buffer

    The buffer containing the data to be transferred.

    timeout

    The timeout that applies to the transfer.

    callback

    The receiver for the TransmitterProtocol method calls (if present).

    progress

    The closure that is invoked after partial transfers (if any).

    Return Value

    See the TransferResult definition.

  • Starts a receiver loop that will call the operations as defined in the ReceiverProtocol on the receiver.

    Note

    There will be no return from this function until a ReceiverProtocol method singals so, or until an error occurs.

    Declaration

    Swift

    public func receiverLoop(
            bufferSize: Int = 20 * 1024,
            duration: TimeInterval = 10,
            receiver: ReceiverProtocol
            )

    Parameters

    bufferSize

    The size of the buffer to create in bytes.

    duration

    The duration for the loop.

    receiver

    The receiver for the ReceiverProtocol method calls (if present).