Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void run() {
try {
TcpSocketServer server = new TcpSocketServer(socketClients, TcpSocketModule.this, cId, options);
socketClients.put(cId, server);
int port = options.getInt("port");
int port = server.getListeningPort();
String host = options.getString("host");
onConnect(cId, host, port);
} catch (Exception uhe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public TcpSocketServer(final ConcurrentHashMap<Integer, TcpSocketClient> socketC
InetAddress localInetAddress = InetAddress.getByName(address);
// Create the socket
serverSocket = new ServerSocket(port, 50, localInetAddress);

// setReuseAddress
try {
boolean reuseAddress = options.getBoolean("reuseAddress");
Expand Down Expand Up @@ -103,4 +104,8 @@ public void close() {
mReceiverListener.onClose(getId(), e.getMessage());
}
}

public int getListeningPort() {
return (serverSocket == null) ? -1 : serverSocket.getLocalPort();
}
}