Link to home
Start Free TrialLog in
Avatar of muskad202
muskad202

asked on

sockets - send(), recv(), TCP, UDP

Hi !!

I had a few queries regarding the send(), recv() functions, and was hoping

someone could help me out ... :)


Blocking Sockets
----------------

(1)  I do a send on a TCP Connection. suppose i'm sending 10240 bytes. will

the send return before all the bytes have been sent (will it return with a

value of 2400 for example, meaning that it sent only 2400 bytes), or will it

always return only after all 10240 bytes have been sent ? (it might return

with a smaller value if the socket was closed before everything could be

sent, but will it return with a smaller value in any other scenario?)

(2) for point (1), What about UDP? will the function only return after all

the data has been sent? and what about the recv function in case of udp? does

it receive all the data at one shot (assuming i pass in a sufficiently large

buffer)?

(3) suppose in one thread, i call send with a huge amount of data to be sent

(e.g. 2 mb) (TCP socket). while this send is progressing, i call send on the

same socket from another thread. will any error be thrown? or will the data

in the second thread be sent after the send returns in the first thread?

(4) for point (3), what will happen if i use a UDP socket instead?

(5) i'm on a 10/100 mbps LAN. I will be calling send quite frequently, say

once every 4 seconds) If i use UDP instead of TCP, will it be faster or

slower? (all the destination PCs are on the same LAN, and in case of TCP, i

will be creating the socket and connect()-ing only once, during

initialization, and not every time i need to do a send.) (i know, udp is less

reliable, but would this unreliability be very much pronounced on a 10/100

mbps LAN?)

thanks :)

muskad202
ASKER CERTIFIED SOLUTION
Avatar of bsnh99
bsnh99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of muskad202
muskad202

ASKER

thanks :)