web server - accept() method

Ben crescent_au at yahoo.com
Fri Nov 7 04:43:59 EST 2003


hi all,

Just trying to figure out what the accept() method in socket.py does.

Lets consider the following webserver code:

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 8881
ock.bind(('',port))
...
...

while 1:
  (newSock, addr) = sock.accept()
   ...
   ...

Here accept() returns newSock and addr. In my case "addr" holds the
value something like: ('127.0.0.1', 2571). What is 2571? This value
keeps changing each time i make a connection to above webserver. What
does this mean?

And also what is "newSock"? It holds value such as: 
<socket object, fd=4, family=2, type=1, protocol=0>
What do i mean by this?

Thanks
Ben




More information about the Python-list mailing list