Answer the question
In order to leave comments, you need to log in
How to properly close a socket?
Client:
Open socket:
Write data:
Socket socket = new Socket(host,port);
socket.getOutputStream().write("str");
socket.getOutputStream().flush();
response = socket.getInputStream().read();
socket.shutdownInput();
socket.shutdownOutput();
socket.close();
Socket clientSocket = serverSocket.accept();
message = clientSocket.getInputStream().read();
clientSocket.getOutputStream().write("str2");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question