On Wed, 6 Sep 2000, Daniel Feiglin wrote:

[... lots of data deleted...]
> When a client comes up, for some reason orother, the header and the
> first first few log records are aggregated by TCP, and appear on
> select() as a single read(). All subsequent client writes are picked up
> correctly.  I can vary the number of initially aggregated records by
> reducing the select() timeout (but not setting it to zero!). The worst
> results are obtained, when I allow select() to block.

TCP is NOT a packet protocol. it is a stream protocol. as such, it may
(and should) aggregate packets when sending. data may be buffer anywhere
along the pass (the sending machine, the receiving machine) and thus you
should NEVER assume that a read will read the same ammount that was writte
on the other side.

thus, you should define a stream format that will allow you to know how
large is the header, and how large is every log record, and read the
appropriate ammount of data (and even then, never assume you read a full
"record" in a single read - you might need to accumulate data until you
read a full packet from the system's buffers.

i suggest that you pick up a good book about how TCP/IP actually works
(e.g. internetworking with TCP/IP, volume I, by douglas comer) before you
continue. there are lots of gotchas with TCP programming that you'll step
on, if you don't know the full story.

> syslog sources (for an example).

syslog is not relevant here - it uses UDP, which is a packet protocol. it
does not use TCP. and don't be tempted to switch to UDP - it's unreliable,
and you'll need to re-program everything that TCP gives you for free.

guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to