Things about socket you should know
If you think that you are a master in socket programming, I believe you know that:
- Calling serverSocket.close() (instance of ServerSocket) won't close the opened socket (created by calling serverSocket.accept()).
- Once ServerSocket is instantiated and without calling serverSocket.accept(), client can build socket connection to the server.
This should be a consideration in how to create codes. Think about this situation. A client assumes that the server has already hold the socket (through serverSocket.accept()). It then sends a message which requires a server response. But the server has not accept any socket call which means there will be no response for the client.
So I think it's a good idea to let the server send a message to client so that client knows the server is ready to have a nice conversation.
Happy socket programming.

Comments
Post new comment