IncomingSocketManager

public class IncomingSocketManager

The IncomingSocketManager class is in charge of managing all of the incoming sockets. In particular, it is in charge of:

  1. On Linux when no special compile options are specified: a. Creating the epoll handle b. Adding new incoming sockets to the epoll descriptor for read events c. Running the “thread” that does the epoll_wait
  2. Creating and managing the IncomingSocketHandlers and IncomingHTTPDataProcessors (one pair per incomng socket)
  3. Cleaning up idle sockets, when new incoming sockets arrive.

Usage Example:

 //Create a manager to manage all of the incoming sockets.
 var manager: IncomingSocketManager?

 override func setUp() {
     manager = IncomingSocketManager()
 }
  • IncomingSocketManager initializer

  • IncomingSocketManager initializer

    Declaration

    Swift

    public init(options: ServerOptions = ServerOptions())
  • Stop this socket manager instance and cleanup resources. If using epoll, it also ends the epoll process() task, closes the epoll fd and releases its thread.

    Usage Example:

    socketManager?.stop()
    

    Declaration

    Swift

    public func stop()
  • Handle a new incoming socket

    Usage Example:

    processor?.handler = handler
    

    Declaration

    Swift

    public func handle(socket: Socket, processor: IncomingSocketProcessor)

    Parameters

    socket

    the incoming socket to handle

    using

    The ServerDelegate to actually handle the socket