|
Home > Archive > Unix Programming > May 2004 > write() on a TCP socket
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
write() on a TCP socket
|
|
| luc wastiaux 2004-05-20, 5:37 pm |
| Hello,
how long does the system call 'write' take to execute ? suppose I want
to send a large amount of data over a TCP socket, will write take a long
time to return ?
thanks.
--
luc wastiaux
| |
| Sony Antony 2004-05-20, 8:34 pm |
|
"luc wastiaux" <dustpuppy@airpost.net> wrote in message
news:c8j3h401sjs@news4.newsguy.com...
> Hello,
>
> how long does the system call 'write' take to execute ? suppose I want
> to send a large amount of data over a TCP socket, will write take a long
> time to return ?
Yes. Theoretically it can take for ever, if the socket is set to blocking.
TCP being a reliable protocol, needs to make sure that all data is being
sent.
So if the client has not read all its previous data, and if the send buffer
is full, write will hang
--sony
>
> thanks.
>
> --
> luc wastiaux
| |
|
| Shouldn't it timeout?
"Sony Antony" <sonyantony@hotmail.com> wrote in message news:<LC9rc.2889$Sc.564@bignews1.bellsouth.net>...
> "luc wastiaux" <dustpuppy@airpost.net> wrote in message
> news:c8j3h401sjs@news4.newsguy.com...
>
> Yes. Theoretically it can take for ever, if the socket is set to blocking.
> TCP being a reliable protocol, needs to make sure that all data is being
> sent.
> So if the client has not read all its previous data, and if the send buffer
> is full, write will hang
[vbcol=seagreen]
>
> --sony
>
>
>
>
| |
|
| It doesn't, automatically. You can set an alarm and a signal handler for
that, to interrupt the system call. On some systems, system calls
auto-restart after a signal handler, so the signal handler should handle
this.
Ash wrote:[vbcol=seagreen]
> Shouldn't it timeout?
>
> "Sony Antony" <sonyantony@hotmail.com> wrote in message news:<LC9rc.2889$Sc.564@bignews1.bellsouth.net>...
>
>
>
|
|
|
|
|