Class ServerSocket

java.lang.Object
net.vincent.communidirect.server.ServerSocket

public class ServerSocket extends Object
Wraps ServerSocket and handles IP resolution and port binding for the CommuniDirect server.

Construct an instance via ServerSocket(ServerLauncher), then call init(String,int) to resolve the address and bind the socket. The bound ServerSocket is exposed via serverSocket so that ClientHandler can call accept() on it.

  • Field Details

  • Constructor Details

    • ServerSocket

      public ServerSocket(ServerLauncher serverLauncher)
      Constructs a ServerSocket bound to the given launcher. Call init(String,int) to complete initialisation.
      Parameters:
      serverLauncher - the owning ServerLauncher
  • Method Details

    • init

      public void init(String ip, int port)
      Resolves ip to an InetAddress, stores port, then calls bindSocket().

      If ip cannot be resolved, falls back to Defaults.DEFAULT_IP. A second resolution failure throws a RuntimeException.

      Parameters:
      ip - the bind address string (hostname or dotted-decimal IPv4)
      port - the TCP port to listen on