hebothu
hebothu

Reputation: 269

If I close a ServerSocket, will the Sockets accepted by the ServerSocket be also closed?

ServerSocket serverSocket = new ServerSocket(some_port);
Socket socket = serverSocket.accept();
serverSocket.close();

Will socket be closed as well?

Upvotes: 7

Views: 806

Answers (1)

user207421
user207421

Reputation: 310957

No. Accepted Sockets are completely independent of the ServerSocket they were accepted from.

Upvotes: 10

Related Questions