Class SocketManager

  • public class SocketManager
    extends java.lang.Object
    Manages the Socket interaction.
    Daniel Sagenschneider
    • Field Detail


        public static final int DEFAULT_SERVER_SOCKET_BACKLOG_SIZE
        Default ServerSocket backlog size.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SocketManager

        public SocketManager​(int listenerCount,
                             int socketReceiveBufferSize,
                             int maxReadsOnSelect,
                             int maxActiveSocketRequests,
                             StreamBufferPool<java.nio.ByteBuffer> bufferPool,
                             int socketSendBufferSize)
        listenerCount - Number of SocketManager.SocketListener instances.
        socketReceiveBufferSize - Receive buffer size for the Socket.
        maxReadsOnSelect - Maximum number of reads per SocketChannel per select. The Selector has locking overheads that slow performance. By undertaking multiple reads on the SocketChannel it makes draining and servicing more efficient (and subsequently faster). This also allows the StreamBuffer sizes to be smaller than the receive Socket buffer size (but still maintain efficiency).
        maxActiveSocketRequests - Maximum number of active SocketManager.SocketRequest instances per accepted Socket.
        bufferPool - StreamBufferPool.
        socketSendBufferSize - Send buffer size for the Socket.
        Throws: - If fails to initialise Socket management.
    • Method Detail

      • getMaxDirectMemory

        public static long getMaxDirectMemory()
        Obtains the max direct memory.
        Max direct memory.
      • getMaxHeapMemory

        public static long getMaxHeapMemory()
        Obtains the max heap memory.
        Max heap memory.
      • getRunnables

        public final java.lang.Runnable[] getRunnables()
        Obtains the Runnable instances to be executed for this SocketManager.
        Runnable instances to be executed for this SocketManager.
      • shutdown

        public final void shutdown()
        Shuts down this SocketManager. This involves closing all Socket instances being managed and stopping the SocketManager.SocketListener instances.
        Throws: - If fails to shutdown this SocketManager.