socket.makefile & AF_UNIX

Jamie Saker w0jrs at firepole.com
Fri Dec 10 20:30:09 EST 2004


>If you're trying to create a Unix socket then mknod() isn't what
>you need.  You probably want to create a socket and bind() it to
>the log file:

>filename = 'snort_alert'
> s = socket(AF_UNIX, SOCK_DGRAM)
> s.bind(filename)

Interesting - I tried this with a local test_log and it worked, creating:

srwxr-xr-x  1 field users   0 Dec 10 19:26 test_log=

which looks like my /dev/log device.

>The call to bind() will probably fail if the socket file already
>exists,

Indeed it does.

> If it's binary then you might need to use s.recv().

Makes sense. Thanks Michael. I'd expect socket.makefile is probably less 
encountered than most aspects of socket (according to google, it sure seemed 
so!).

Jamie



More information about the Python-list mailing list