UNIX domain sockets problem

Grant Edwards grante at visi.com
Sat Apr 7 23:20:18 EDT 2001


On Sat, 7 Apr 2001 16:30:00 -0400, Steven D. Arnold <stevena at permanent.cc> wrote:

>I'm trying to create a server that uses UNIX domain sockets.  I
>am using the code below:
>
>	from socket import *
>	from os import unlink
>
>	SERVER = socket(AF_UNIX, SOCK_DGRAM, 0)
>	unlink("/home/stevena/socket")
>	SERVER.bind("/home/stevena/socket")
>	SERVER.listen(3)

You can't listen() for connections on a connectionless
protocol.  The listen() operation is only valid for
connection-oriented protocols, and not for datagram protocols.

       To  accept  connections,  a  socket  is first created with
       socket(2), a willingness to  accept  incoming  connections
       and  a  queue limit for incoming connections are specified
       with listen, and then the connections  are  accepted  with
       accept(2).   The  listen  call  applies only to sockets of
       type SOCK_STREAM or SOCK_SEQPACKET.
       
>This is on a machine running Linux-PPC, using python 1.5.1.
>I'll try it on regular RedHat Linux tomorrow, but surely
>listen() would be supported on Linux-PPC?  Anyone have a clue
>what's going on?

Skip the listen() call and just call recv().

-- 
Grant Edwards                   grante             Yow!  Youth of today! Join
                                  at               me in a mass rally
                               visi.com            for traditional mental
                                                   attitudes!



More information about the Python-list mailing list