java.lang.Object
net.i2p.i2pcontrol.SocketController
All Implemented Interfaces:
ClientApp, RouterApp

public class SocketControllerextends Object implements RouterApp
This handles the starting and stopping of a ServerSocket from a single static class so it can be called via clients.config. This class is NOT used for the webapp or the HTTP/HTTPS implementation.
  • Field Details

  • Constructor Details

    • SocketController

      public SocketController(RouterContext ctx, ClientAppManager mgr) throws IOException
      RouterApp (new way)
      Parameters:
      ctx - the router context supplying the log manager and config directory
      mgr - the client app manager notified of state changes, or null when run outside the client app framework
      Throws:
      IOException - declared by the client app instantiation contract, though this constructor body performs no failing I/O
  • Method Details

    • startup

      public void startup()
      Start the socket server
      Specified by:
      startup in interface ClientApp
    • shutdown

      public void shutdown(String[] args)
      Stop the socket server
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
    • getState

      public ClientAppState getState()
      Current state of the managed client app.
      Specified by:
      getState in interface ClientApp
      Returns:
      current state
    • getName

      public String getName()
      Unique name of the client app.
      Specified by:
      getName in interface ClientApp
      Returns:
      "I2PControl-Socket"
    • getDisplayName

      public String getDisplayName()
      Display name of the client app.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      "I2PControl-Socket"
    • buildServer

      public ServerSocket buildServer() throws IOException
      Builds a new server. Used for changing ports during operation and such. Does NOT start the server. Must call start() on the returned server.
      Returns:
      Server - A new server built from current configuration.
      Throws:
      IOException - if the configured listen address cannot be resolved, the configured port is already bound, or the configuration file cannot be written back