Networking Forums

Networking Forums > Computer Networking > Linux Networking > Unix domain socket: can't test for blocking before sendto

Reply
Thread Tools Display Modes

Unix domain socket: can't test for blocking before sendto

 
 
Poluekt
Guest
Posts: n/a

 
      04-01-2004, 06:48 PM
I have two processes connected through Unix domain socket. In the
"sender" process I am calling select in order to check if sendto call
will block, because the receiver can't keep pace with the sender. From
the some reason select _always_ indicates that there will be no
blocking, but when I call sendto with MSG_DONTWAIT flag, it fails with
errno equal to EAGAIN.

My question is: why select always marks the socket as ready ?

The receiver code (in the sake of simplicity it never reads from the
socket):

sock = socket(PF_UNIX, SOCK_DGRAM, 0);

memset(&addr, 0, sizeof(addr));
addr.sun_family = PF_UNIX;
sprintf(addr.sun_path, "/tmp/receiver");
unlink("/tmp/receiver");

stat = bind(sock, (struct sockaddr *)&addr, sizeof(struct
sockaddr_un));

while(1)
;

The sender code:

sock = socket(PF_UNIX, SOCK_DGRAM, 0);

memset(&addr, 0, sizeof(addr));
addr.sun_family = PF_UNIX;
sprintf(addr.sun_path, "/tmp/sender.%d", getpid());

stat = bind(sock, (struct sockaddr *)&addr, sizeof(struct
sockaddr_un));

addr.sun_family = PF_UNIX;
sprintf(addr.sun_path, "/tmp/receiver");

while(1)
{
FD_ZERO(&wfds);
FD_SET(sock, &wfds);
tv.tv_sec = TOUT_SEC;
tv.tv_usec = TOUT_USEC;

do
stat = select(sock+1, 0, &wfds, 0, &tv);
while (-1 == stat && EINTR == errno);

/*
FD_ISSET is always true and after a couple of successful
calls
sendto starts to fail with EAGAIN
*/
if (FD_ISSET(sock, &wfds))
stat = sendto(sock, msg, sizeof(msg), MSG_DONTWAIT,
(struct sockaddr *)&addr, sizeof(addr));
}

Any help will be greatly appreciated.
 
Reply With Quote
 
 
 
 
Cameron Kerr
Guest
Posts: n/a

 
      04-02-2004, 06:51 AM
Poluekt <(E-Mail Removed)> wrote:
> I have two processes connected through Unix domain socket. In the
> "sender" process I am calling select in order to check if sendto call
> will block, because the receiver can't keep pace with the sender. From
> the some reason select _always_ indicates that there will be no
> blocking, but when I call sendto with MSG_DONTWAIT flag, it fails with
> errno equal to EAGAIN.
>
> My question is: why select always marks the socket as ready ?


Are you sure this behaivour is in error?

1) Check your return codes for errors.

2) Run your program through strace (or truss on other platforms) to see
what your system calls are doing.

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
 
Reply With Quote
 
svm svm is offline
Junior Member
Join Date: Nov 2010
Posts: 1

 
      11-22-2010, 07:27 PM
Hi,

I am facing the same problem. Was this issue fixed?

Alternatively, what are the options to deal with the "Resource temporarily unavailable" error returned with Unix domain sockets, besides
1) Increase the receive buffer size (/proc/sys/net/unix/amx_dgram_qlen)
2) Check if send will fail using select (this does not seem to be working)

Thank you for your time,
Vidya
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sniff local IPC via Unix Domain Socket sjhesse@gmail.com Linux Networking 0 06-02-2007 08:21 PM
Telnet equivalent to Unix domain socket? hobinyoon@gmail.com Linux Networking 1 01-30-2007 11:57 AM
linux improper 0 return from read on blocking unix domain socket tx_scott_stevens@yahoo.com Linux Networking 0 11-18-2005 10:11 PM
Tool to Dump Unix Domain Socket Traffic? Hokousha Linux Networking 0 05-26-2004 02:09 AM
RAW socket when sendto() always return -1(ENOBUFS) ??????? hzcl Linux Networking 0 08-15-2003 09:07 AM



1 2 3 4 5 6 7 8 9 10 11