Class ServerSocket
java.lang.Object
net.vincent.communidirect.server.ServerSocket
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 Summary
FieldsModifier and TypeFieldDescriptionResolved bind address set byinit(String,int).intBind port set byinit(String,int).The underlying JDK server socket; populated bybindSocket(). -
Constructor Summary
ConstructorsConstructorDescriptionServerSocket(ServerLauncher serverLauncher) Constructs aServerSocketbound to the given launcher. -
Method Summary
Modifier and TypeMethodDescriptionvoid
-
Field Details
-
serverSocket
The underlying JDK server socket; populated bybindSocket(). -
ip
Resolved bind address set byinit(String,int). -
port
public int portBind port set byinit(String,int).
-
-
Constructor Details
-
ServerSocket
Constructs aServerSocketbound to the given launcher. Callinit(String,int)to complete initialisation.- Parameters:
serverLauncher- the owningServerLauncher
-
-
Method Details
-
init
Resolvesipto anInetAddress, storesport, then callsbindSocket().If
ipcannot be resolved, falls back toDefaults.DEFAULT_IP. A second resolution failure throws aRuntimeException.- Parameters:
ip- the bind address string (hostname or dotted-decimal IPv4)port- the TCP port to listen on
-