getting data from a port in use

Dana Marcusanu dmarcusanu at yahoo.com
Mon Jan 31 21:13:00 EST 2005


Hi to all,
I am trying to use Python to get the data received at a specific port (in
use) on my computer. I already tried below code which seems to hang at the
statement accepting connections. I don't know what else I can try. Any
suggestions will be welcome.

import socket, select, os 

PORT = 2005
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 
s.bind((socket.gethostname(), PORT))
s.listen(1)
work_socket, addr = s.accept() 
data = s.recv(1024)
print data
s.close()

Thank you, Dana


		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 




More information about the Python-list mailing list