Sockets : good practices for opening and closing ?
Posted: Fri Apr 02, 2010 11:22 am
I have a server and 2 clients, using sockets.
Very simple application : a client sends a query to the server, the server sends back a result.
My question is : what are the good practices regarding opening/closing socket on the client side ?
Is it better to close the socket after each read commands ?
In other words.
For the client :
-for each query, I open
-I write the query
-then i read the result sent by the server
-and then I should ?
Or is it better to close socket on the server side ?
Very simple application : a client sends a query to the server, the server sends back a result.
My question is : what are the good practices regarding opening/closing socket on the client side ?
Is it better to close the socket after each read commands ?
In other words.
For the client :
-for each query, I open
Code: Select all
open socket to fld "ip" with message connected
-then i read the result sent by the server
-and then I should
Code: Select all
close socket theIP
Or is it better to close socket on the server side ?