socket.makefile & AF_UNIX
Michael Fuhr
mfuhr at fuhr.org
Fri Dec 10 18:44:37 EST 2004
More information about the Python-list mailing list
Fri Dec 10 18:44:37 EST 2004
- Previous message (by thread): socket.makefile & AF_UNIX
- Next message (by thread): socket.makefile & AF_UNIX
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jamie Saker <w0jrs at firepole.com> writes: > In the makefile operation on socket (pydoc socket.socket.makefile... using > AF_UNIX, allowing you to create a file object to correspond to a socket) I've > got an sample program (goal: open up unix file socket object for snort's > alert_unixsock output mode to dump to. later, take data written into file > object and process) as follows: 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) The call to bind() will probably fail if the socket file already exists, so you might want to unlink it first (or make sure you clean up by unlinking it whenever you exit). Whether it's appropriate to call makefile() and use methods like readline() depends on the format of the data that the other end will send. If it's binary then you might need to use s.recv(). -- Michael Fuhr http://www.fuhr.org/~mfuhr/
- Previous message (by thread): socket.makefile & AF_UNIX
- Next message (by thread): socket.makefile & AF_UNIX
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list