Click to See Complete Forum and Search --> : send() and recv() parameters confusion


adi.shoukat
October 8th, 2009, 06:06 AM
On server Side:
int recv (Socket,Buffer, Length, Flags)
On Client Side:
int send (Socket,Message, Length, Flags)


can anyone plz tell me weather the 1st parameter in both of above is the same thing or not??
if no .... plz tell me how to know that both the above commands are sending/receiving from same socket.

adi.shoukat
October 8th, 2009, 07:27 AM
send( socket , , ,0);

recv( socket , , ,0);


if one of them is on client side and the other is on server side .... and on both side integer socket that I pass to these functions has same value ... can I say that this recv() is for respective send()

hoxsiew
October 8th, 2009, 09:29 AM
I'm not sure I understand your second question, but as to your first question, both send and recv are designed to handle any arbitrary bitstream. The Length parameter tells each how many bytes to send or to expect to be received. The return values of both send and recv should be checked to ensure that the entire amount has been sent/received and if not, should loop until it is. It is up to the programmer to ensure that the stream is correctly parsed/cast on each end of the transaction.

Richard.J
October 8th, 2009, 01:24 PM
A socket connection is described by the 5-tupel (local IP address, local port, remote IP address, remote port, protocol).
So the server and client both have the same values to describe the connection, but in different order (wrt local/remote).
The "socket" itself is a resource descriptor, and its value can be anything meaningful to the underlying OS.

HTH,
Richard