|
Home > Archive > Unix Programming > December 2005 > sendto blocks for unix datagram 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 |
sendto blocks for unix datagram socket
|
|
| girishdkale@yahoo.com 2005-12-20, 5:57 pm |
| Hi,
I am using unix datagram socket to send messages from one process to
another process.
I am using a blocking socket. I observed that the sendto call blocks
for a long time in "some scenario". This does not happen always.
I have set the following parameters:
sh-2.05b# cat /proc/sys/net/core/wmem_max
131071
sh-2.05b# cat /proc/sys/net/core/wmem_default
106496
sh-2.05b# cat /proc/sys/net/core/rmem_default
106496
sh-2.05b# cat /proc/sys/net/core/rmem_max
131071
sh-2.05b# cat /proc/sys/net/core/netdev_max_backlog
300
sh-2.05b# cat /proc/sys/net/unix/max_dgram_qlen
200
How do I debug this issue?
What are the scenarios when the sendto will block?
Regards,
Girish
| |
| David Schwartz 2005-12-20, 5:57 pm |
|
<girishdkale@yahoo.com> wrote in message
news:1135104175.454998.172520@g44g2000cwa.googlegroups.com...
> I am using a blocking socket. I observed that the sendto call blocks
> for a long time in "some scenario". This does not happen always.
If you don't want to block until the 'sendto' can complete, why are you
using blocking sockets?
> What are the scenarios when the sendto will block?
Perhaps the network interface's buffer is full? Perhaps the network
interface has no link?
DS
| |
| Barry Margolin 2005-12-20, 5:57 pm |
| In article <do9jtb$6su$1@nntp.webmaster.com>,
"David Schwartz" <davids@webmaster.com> wrote:
> <girishdkale@yahoo.com> wrote in message
> news:1135104175.454998.172520@g44g2000cwa.googlegroups.com...
>
>
> If you don't want to block until the 'sendto' can complete, why are you
> using blocking sockets?
>
>
> Perhaps the network interface's buffer is full? Perhaps the network
> interface has no link?
What network interface? I assume that by "unix datagram socket" he
means "unix domain datagram socket". Is this correct, girishdkale?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| David Schwartz 2005-12-20, 5:57 pm |
|
"Barry Margolin" <barmar@alum.mit.edu> wrote in message
news:barmar-BC25D1.15283720122005@comcast.dca.giganews.com...
> What network interface? I assume that by "unix datagram socket" he
> means "unix domain datagram socket". Is this correct, girishdkale?
Ahh, you're right. Then most likely he's waiting for the other
application to read from the socket.
DS
| |
| girishdkale@yahoo.com 2005-12-21, 2:52 am |
| Hi,
Yes, I am using unix domain datagram sockets.
However the last sentence is a bit unclear -
If application A sends data to Application B, will the sendto call of
App A not return till the app B reads the data from its socket?
Regards,
Girish
| |
| Nils O. Selåsdal 2005-12-21, 2:52 am |
| girishdkale@yahoo.com wrote:
> Hi,
>
> Yes, I am using unix domain datagram sockets.
>
> However the last sentence is a bit unclear -
> If application A sends data to Application B, will the sendto call of
> App A not return till the app B reads the data from its socket?
There is likely a little kernel buffer, quite so often unix sockets
are implemented on the same mechanism as normal pipes, and they
work much the same way. You block on sending when the buffer is full.
| |
| girishdkale@yahoo.com 2005-12-21, 7:56 am |
| hi,
If the buffer is not full, will it block?
We tried to send 70 messages from App A to App B, with the above given
kernel parameters. In App B there we put a sleep of 2 secs after it
receives this message from App A. Observation is that the App A also
waits for 2 secs before it sends the next message.
Thanks,
Girish
| |
| Maxim Yegorushkin 2005-12-21, 7:56 am |
|
girishdkale@yahoo.com wrote:
>
> If the buffer is not full, will it block?
It depends on implementation. If you don't want to block use
nonblocking IO.
| |
| Nils O. Selåsdal 2005-12-21, 7:56 am |
| girishdkale@yahoo.com wrote:
> hi,
>
> If the buffer is not full, will it block?
>
> We tried to send 70 messages from App A to App B, with the above given
> kernel parameters. In App B there we put a sleep of 2 secs after it
> receives this message from App A. Observation is that the App A also
> waits for 2 secs before it sends the next message.
Then you have your answer from these observations.
Of interrest, how big was each message you sent ?
| |
| David Schwartz 2005-12-21, 5:57 pm |
|
<girishdkale@yahoo.com> wrote in message
news:1135163437.309936.28000@g44g2000cwa.googlegroups.com...
> If the buffer is not full, will it block?
If you are using a blocking socket, it can block for as long as it
likes. In practice, it will block until the kernel buffer is not full. If
data is being sent faster than it is being received, eventually the buffer
will fill up and the sender will not be allowed to run faster than the
receiver.
> We tried to send 70 messages from App A to App B, with the above given
> kernel parameters. In App B there we put a sleep of 2 secs after it
> receives this message from App A. Observation is that the App A also
> waits for 2 secs before it sends the next message.
Imagine if the buffer is big enough to hold 30 messages and you are
sending a message every second but only receiving one every two seconds.
After 30 seconds, the sender will be blocked for a second, guaranteed. After
that, the sender will be blocked so that it runs no faster than the
receiver.
This is true for any fixed buffer size, so long as the sender sends data
faster than the receiver receives it.
DS
|
|
|
|
|