Socket Programming Question:
Download Job Interview Questions and Answers PDF
How do I close sockets?
![Socket Programming Interview Answer Socket Programming Interview Question](https://globalguideline.com/public/images/interview/6.png)
Answer:
You should always close the output and input stream before you close the socket.
On the client side:
try {
output.close();
input.close();
MyClient.close();
}
catch (IOException e) {
System.out.println(e);
}
On the server side:
try {
output.close();
input.close();
serviceSocket.close();
MyService.close();
}
catch (IOException e) {
System.out.println(e);
}
On the client side:
try {
output.close();
input.close();
MyClient.close();
}
catch (IOException e) {
System.out.println(e);
}
On the server side:
try {
output.close();
input.close();
serviceSocket.close();
MyService.close();
}
catch (IOException e) {
System.out.println(e);
}
Download Socket Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
How do I create an output stream? | Explain simple mail transfer protocol? |