PF_UNIX socket problem in 2.4

PF_UNIX socket problem in 2.4

Post by Matej Pfajfa » Sun, 03 Feb 2002 23:40:09



Hi,

After upgrading to kernel 2.4.18pre7 (from 2.2.19), a recv() operation on
a UNIX socket returns 11 (EGAIN) even though the socket is blocking. My
code worked fine on 2.2.19.

I am doing some more debugging to see why this happens but I would like to
ask whether anyone else has had similar problems? Is this a known bug?
Thank you,

Matej

Matej Pfajfar
St John's College, University of Cambridge, UK


Most people are good people, the rest of us are going to
run the world. -- badbytes

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

PF_UNIX socket problem in 2.4

Post by Alan Co » Mon, 04 Feb 2002 04:30:11


Quote:> After upgrading to kernel 2.4.18pre7 (from 2.2.19), a recv() operation on
> a UNIX socket returns 11 (EGAIN) even though the socket is blocking. My
> code worked fine on 2.2.19.

> I am doing some more debugging to see why this happens but I would like to
> ask whether anyone else has had similar problems? Is this a known bug?

Not a known one. A small test case would be good
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

PF_UNIX socket problem in 2.4

Post by Matej Pfajfa » Tue, 05 Feb 2002 04:10:09


Quote:> > After upgrading to kernel 2.4.18pre7 (from 2.2.19), a recv() operation on
> > a UNIX socket returns 11 (EGAIN) even though the socket is blocking. My
> > code worked fine on 2.2.19.

> > I am doing some more debugging to see why this happens but I would like to
> > ask whether anyone else has had similar problems? Is this a known bug?

> Not a known one. A small test case would be good

The problem was caused when my code tried to read 0 bytes from a unix
socket (my fault, didn't specifically check for wanting to read 0 bytes,
assumed recv() would just return 0 ...).

When there is no data available, the code blocks. If, however, data is
available, recv() returns EGAIN. Is this correct behaviour? In kernel
2.2.19, recv() did in fact return 0;

Test example below.

Matej

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char *argv[])
{
  char buf[1];
  int s;
  int retval;
  struct sockaddr_un server;

  if (argc < 2)
    printf("Usage : test socketname");

  s = socket(PF_UNIX, SOCK_STREAM, 0);
  if (s < 0)
    perror("socket :");
  else
  {
    server.sun_family = PF_LOCAL;
    strncpy(server.sun_path, argv[1], sizeof(server.sun_path));

    if (connect(s,(struct sockaddr *)&server,SUN_LEN(&server)) < 0)
      perror("connect :");
    else
    {
      retval = recv(s,buf,0, 0);
      if (retval < 0)
        perror("recv :");
      else
        printf("Received %u bytes.",retval);

      close(s);
      return 0;
    }
  }

Quote:}

Matej Pfajfar
St John's College, University of Cambridge, UK


Most people are good people, the rest of us are going to
run the world. -- badbytes

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. PF_UNIX sockets questions

Working on the AIX platform, we plan to use PF_UNIX domain sockets for
communication between processes in the same processor.  The sender uses the
sendmsg routine and receiver uses the recvmsg routine.

Is it necessary for the receiver to loop on the recvmsg call until some
known amount of data is fetched (as done with PF_INET sockets)?
Will the recvmsg call always fetch a single message that was sent by a
sendmsg call?
Does the answer depend on the socket type (DGRAM vs STREAM)?
Does it matter if the sendmsg routine always sends a file descriptor along
with data?
Has anyone done this before and know the answer from actual experience?

Please note neither TCP nor UDP is involved here.


Thanks for your responses.

2. ATI 3D RAGE

3. Problem with reading sockets in 2.4 ??

4. Mandrake 9.2 and HP 5550

5. Socket problem under Solaris 2.4/5

6. FreeBSD and DVD-RAM

7. Problem setting non blocking I/O for socket under 2.4

8. WinNuke for Windows 95 & NT

9. Solaris 2.4 non-blocking socket i/o problem

10. Solaris 2.4: Problem in Port/Socket access

11. problem listening to raw socket in Linux kernel 2.4

12. PROBLEM: my Aviator Webgear 2.4 doesn't work with kernel version 2.4.x

13. 2.4 X86: ftp error, socket permission denied?