Re: sockts and read() write()
From: Graham Murray
Date: Thu Jun 18 2009 - 03:59:19 EST
ranjith kumar <ranjithproxy@xxxxxxxxx> writes:
> Hi,
> I am new to socket programming.
>
> There are two programs(client on target machine, server on host
> machine ) , communicating through a single socket.
>
> Server program writes data of (say) 100bytes, 200 bytes, 500 bytes and
> 1000bytes, suceessively calling write() 4 times.
>
> My question is on client side, if I call read() 4 times, will get
> 100bytes, 200bytes, 500bytes and 1000bytes of data successively and
> ALWAYS? Or is it possible that with a single read() I may get all
> 100+200+500+1000bytes of data???
If you are using UDP, then you will get 100, 200, 500 and 1000 bytes in
4 calls() to read. If you are using TCP, then you could get all 1800
bytes in a single call, or it may need multiple calls to read().
--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html