Networking Forums

Networking Forums > Computer Networking > Linux Networking > socket stream

Reply
Thread Tools Display Modes

socket stream

 
 
captain biceps
Guest
Posts: n/a

 
      08-19-2004, 07:52 PM
Hello guys,

Under C, I set the tcp windows size buffer (input and output) with
setsockopt to a 128k size...(example)

My client "send()" 256ko of datas to my waiting socket

On the server side, I wait with a "recv(sock, buf, 256000,0)" like...

But now, my tcp windows size seems to be "too small" to handle all the 256ko
no ?
What happens is this case ?
I mean, the recv function (internally) will fetch my data in two passes ?

thanx









 
Reply With Quote
 
 
 
 
Bob Hauck
Guest
Posts: n/a

 
      08-19-2004, 08:47 PM
On Thu, 19 Aug 2004 21:52:27 +0200, captain biceps <(E-Mail Removed)> wrote:

> But now, my tcp windows size seems to be "too small" to handle all the
> 256ko no ? What happens is this case ? I mean, the recv function
> (internally) will fetch my data in two passes ?


You will get the data in whatever size chunks you get it in. It will
take however many passes it takes. The TCP window size doesn't
guarantee anything in that regard.

In general you should not ever assume that TCP will deliver data in any
particular chunk size, because sooner rather than later your assumption
will be wrong. It is a stream protocol, not a datagram protocol. Think
of TCP as a serial port with unknown and jittery timing.

What you need to do is create some way of telling when you have received
a complete message. Some options are a header with a byte count, a
record separator (e.g. newline), or inserting special data of some kind
in the stream. However you do it the point is that you need to be able
to find the start and end of a message independent of how many times you
have to call read() to get the whole thing.

Or you could use UDP with your own retry mechanism.


--
-| Bob Hauck
-| To Whom You Are Speaking
-| http://www.haucks.org/
 
Reply With Quote
 
Pirabhu Raman
Guest
Posts: n/a

 
      08-19-2004, 10:24 PM
"captain biceps" <(E-Mail Removed)> wrote in message
news:cg30dq$30a$(E-Mail Removed)...
> Hello guys,
>
> Under C, I set the tcp windows size buffer (input and output) with
> setsockopt to a 128k size...(example)
>
> My client "send()" 256ko of datas to my waiting socket
>
> On the server side, I wait with a "recv(sock, buf, 256000,0)" like...
>
> But now, my tcp windows size seems to be "too small" to handle all the

256ko
> no ?
> What happens is this case ?
> I mean, the recv function (internally) will fetch my data in two passes ?
>
> thanx


Socket buffer size does not imply how much data you can send or receive. It
implies how much data one host can push to another host before getting an
acknowledgement from other(this is a TCP level ack which is end-to-end).

Say ur client is sending 256k and server is busy with some other process.
Now the client can send upto 128k of data as that is what the server
advertised as buffer size (even if client has a buffer size of 256k). After
sending the 128k the client must wait till it receives an acknowledgement
from server saying this much more buffer has been freed e.g. 64k in which
case client can send 64k more.

Ofcourse in real world, the server would process these bytes according to
its work load and get back to client as and when received bytes are
processed, letting client know that some more buffer has been freed. Please
refer to sliding window protocol in Data Communications by Stallings or
Computer Networks by Tanenbaum for better description.

Thus based on how fast the server can process the received bytes and free
the buffer, you might have anywhere from 2 to unknown number of phases.

This protocol is an end-to-end protocol and is layered upon the others
including link layer. This protocol works same way irrespective of the type
of network you use. Lets see as an example how this works on top of
ethernet, which employs a packet size of 1500 bytes. When the client says it
wants to send 128k (it cannot offer to send more than that), the network
interface splits this 128k into packets each of size 1500 bytes and sends
them on network. These link layer packets are governed by a hop-based flow
control where an intermediate switch/router/host mandates how many packets
your host can send before receiving an acknowledgement.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test socket on Master Socket not working Kevin Cowans Broadband 14 11-15-2006 09:17 PM
Data Stream to IP Stream John Edgar Broadband 2 04-30-2005 09:11 AM
Virgin ADSL - IP Stream or Data Stream ??? DeeBee Broadband 19 03-06-2005 11:28 AM
10038 Socket Operation on non-socket error Tim G Windows Networking 1 09-26-2004 03:04 PM
WLAN Monitor 10038 Socket operation on non-socket Bill Windows Networking 1 03-01-2004 10:34 PM



1 2 3 4 5 6 7 8 9 10 11