On 3 Apr 2007 08:43:57 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Apr 3, 10:29 am, "Maxim Veksler" <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I wish to do some low level network stuff using python. > > > > -- > > Cheers, > > Maxim Veksler > > > > "Free as in Freedom" - Do u GNU ? > > I would assume you could use the socket module. This post details > someone else who opened ports with Python: > > http://www.thescripts.com/forum/thread44280.html > > Here's another resource using some python servers: > > http://docs.python.org/lib/socket-example.html > > Finally, a Socket programming howto: > http://www.amk.ca/python/howto/sockets/ > > I'm also told that the Twisted framework is excellent for this sort of > thing. >
Thanks for the heads-up. The sockets howto was great help. I'm trying to bind a non-blocking socket, here is my code: """ #!/usr/bin/env python import socket, select from time import sleep s_nb10000 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s_nb10000.setblocking(0) s_nb10000.bind(('192.168.2.106', 10002)) s_nb10000.listen(5) while 1: conn, addr = s_nb10000.accept() ready_to_read, ready_to_write, in_error = select.select([conn], [], [], 0) print (ready_to_read, ready_to_write, in_error) sleep(100) s_nb10000.close() """ And this is the exception I'm getting: """ python non_blocking_socket.py Traceback (most recent call last): File "non_blocking_socket.py", line 13, in ? conn, addr = s_nb10000.accept() File "/usr/lib/python2.4/socket.py", line 161, in accept sock, addr = self._sock.accept() socket.error: (11, 'Resource temporarily unavailable') """ What am I doing wrong here? p.s. I've looked at twisted before posting this post. I've seen they impelement alot of application level protocols but I didn't see much treatment for low level "raw" network data, not to mention that it's a way way over kill for what I'm asking to achieve. Twisted does have a subproject called "Twisted Pair: Low-level networking" but sadly it's unmaintained and undocumented. > Mike > Maxim. -- Cheers, Maxim Veksler "Free as in Freedom" - Do u GNU ? -- http://mail.python.org/mailman/listinfo/python-list