sendto blocks for unix datagram socket
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > sendto blocks for unix datagram socket




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    sendto blocks for unix datagram socket  
girishdkale@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-20-05 10: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






[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-20-05 10: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







[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
Barry Margolin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-20-05 10: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 yo
u
> 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 ***





[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-20-05 10: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







[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
girishdkale@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 07: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






[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
Nils O. Selåsdal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 07: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.





[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
girishdkale@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 12:56 PM

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






[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
Maxim Yegorushkin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 12:56 PM


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.






[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
Nils O. Selåsdal


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 12:56 PM

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 ?





[ Post a follow-up to this message ]



    Re: sendto blocks for unix datagram socket  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-21-05 10: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







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:24 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register