aukxn
aukxn

Reputation: 231

If socket created by ServerSocket.accept() is closed but the socket on client side isn't, will ServerSocket.accept() accept it again?

Let say A is Server and B is Client. B create a socket b to Server A and ServerSocket.accept() create a corresponding socket a for the client B now if a is closed by Server A but client B haven't closed its socket b and ServerSocket.accept() still running then will ServerSocket.accept() create another socket cfor client B again?

Upvotes: 0

Views: 308

Answers (1)

Samuel Davidson
Samuel Davidson

Reputation: 791

No

When either the Server A or Client B closes the connection, the connection is closed for the sockets on both. The client will need to initialize a new connection in order for a new socket c to be created. ServerSocket.accept() will only return when the client explicitly requests a new connection.

Upvotes: 3

Related Questions