Re: delay on select()
From: Andrei Voropaev (avorop_at_mail.ru)
Date: 12/30/03
- Previous message: David Schwartz: "Re: delay on select()"
- In reply to: David Schwartz: "Re: delay on select()"
- Next in thread: David Schwartz: "Re: delay on select()"
- Reply: David Schwartz: "Re: delay on select()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Dec 2003 08:11:54 GMT
On 2003-12-30, David Schwartz <davids@webmaster.com> wrote:
>
> "Shuqing Wu" <swu@sympatico.ca> wrote in message
> news:rF1Ib.3593$Vl6.936305@news20.bellglobal.com...
>
>
>>I execute an distributed application on LAN.
>> When a cleant send( ) some message to server, it
>> takes about 100 milliseconds to select( ) for that
>> message. Is it normal?
>
> Yes.
>
>> What is the possible reason
>> for that?
>
>
> The client isn't being smart about the amount of data it passes to the
> stack at a time. When the stack sees the first send, it has no idea there's
> going to be a second, so it sends the data immediately. When it sees the
> second send, it has no idea there isn't going to be a third, so it delays
> the data by about 200 milliseconds or so.
>
> The solution is for programs that send data over TCP to properly manage
> their transfer of data from the application to the network stack. For
> example, if you have to send three lines of data at the same time, send them
> in one call to 'send' or 'write' rather than in three. Here, 'at the same
> time' means 'without having to wait for anything in-between them'.
This would work, but makes life really miserable. Not always it is
possible to join things into one package. Really you'd have to
reimplement buffering that system already implements. Better to use
socket options in this case. (Though I'm not sure about being portable
here). Anyway. On Linux man 7 tcp lists TCP_NODELAY that
allows immidiate sending of data in the TCP buffers, the reverse of it
is TCP_CORK that allows to assemble package in system buffers and then
send it as one.
Andrei
- Previous message: David Schwartz: "Re: delay on select()"
- In reply to: David Schwartz: "Re: delay on select()"
- Next in thread: David Schwartz: "Re: delay on select()"
- Reply: David Schwartz: "Re: delay on select()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|