Class ThreadedSocketService

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class ThreadedSocketService extends SocketService

A GThreadedSocketService is a simple subclass of SocketService that handles incoming connections by creating a worker thread and dispatching the connection to it by emitting the Gio.ThreadedSocketService::run signal in the new thread.

The signal handler may perform blocking I/O and need not return until the connection is closed.

The service is implemented using a thread pool, so there is a limited amount of threads available to serve incoming requests. The service automatically stops the SocketService from accepting new connections when all threads are busy.

As with SocketService, you may connect to Gio.ThreadedSocketService::run, or subclass and override the default handler.

Since:
2.22
  • Constructor Details

    • ThreadedSocketService

      public ThreadedSocketService(MemorySegment address)
      Create a ThreadedSocketService instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ThreadedSocketService

      public ThreadedSocketService(int maxThreads)
      Creates a new GThreadedSocketService with no listeners. Listeners must be added with one of the GSocketListener "add" methods.
      Parameters:
      maxThreads - the maximal number of threads to execute concurrently handling incoming clients, -1 means no limit
      Since:
      2.22
    • ThreadedSocketService

      public ThreadedSocketService()
      Create a new ThreadedSocketService.
  • Method Details