IncomingSocketProcessor

public protocol IncomingSocketProcessor : AnyObject

This protocol defines the API of the classes used to process the data that comes in from a client’s request. There should be one IncomingSocketProcessor instance per incoming request.

  • The socket if idle will be kep alive until…

    Declaration

    Swift

    var keepAliveUntil: TimeInterval { get set }
  • A flag to indicate that the socket has a request in progress

    Declaration

    Swift

    var inProgress: Bool { get set }
  • A back reference to the IncomingSocketHandler processing the socket that this IncomingDataProcessor is processing.

    Declaration

    Swift

    var handler: IncomingSocketHandler? { get set }
  • Process data read from the socket.

    Declaration

    Swift

    func process(_ buffer: NSData) -> Bool

    Parameters

    buffer

    An NSData object containing the data that was read in and needs to be processed.

    Return Value

    true if the data was processed, false if it needs to be processed later.

  • Write data to the socket

    Declaration

    Swift

    func write(from data: NSData)

    Parameters

    from

    An NSData object containing the bytes to be written to the socket.

  • Write a sequence of bytes in an array to the socket

    Declaration

    Swift

    func write(from bytes: UnsafeRawPointer, length: Int)

    Parameters

    from

    An UnsafeRawPointer to the sequence of bytes to be written to the socket.

    length

    The number of bytes to write to the socket.

  • Close the socket and mark this handler as no longer in progress.

    Declaration

    Swift

    func close()
  • Called by the IncomingSocketHandler to tell the IncomingSocketProcessor that the socket has been closed by the remote side.

    Declaration

    Swift

    func socketClosed()