我在Java套接字编程中有几个问题。
最佳答案
while reading the inputstream in client socket, if it throws IO exception; then do we need to reconnect the server socket/ reintialize the client socket again?
是的,除非它是读取操作上的
SocketTimeoutException
。if we close the output stream, will it closes the client socket?
是的。
in client socket, if the message read from the inputstream is different as what we expected; do we have any standard to handle this?
否。如果该消息完全无法识别,则您可能需要切断连接。如果是已识别的消息但顺序不正确,则可能是编程错误,也可能是您在设计时没有想到的情况。解决方案:现在考虑一下。
关于java - 读/写Java套接字流时的澄清,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43437011/