[PEAK] tools.server.url

Bob Ippolito bob at redivi.com
Tue Oct 19 16:18:08 EDT 2004


On Oct 19, 2004, at 15:50, Phillip J. Eby wrote:

> Also, I'm surprised that using port 0 doesn't work to allocate an 
> available port.  That almost seems to me like something's broken in 
> OS/X, but maybe it's a general BSD thing.  (Ty: any thoughts on that?  
> Bob?)

It works on OS X 10.3.. I don't know why it doesn't work in his 
application.

 >>> import socket
 >>> sockets = socket.getaddrinfo(None, 0, 0, socket.SOCK_STREAM, 0, 
socket.AI_PASSIVE)
 >>> sockets
[(30, 1, 6, '', ('::', 0, 0, 0)), (2, 1, 6, '', ('0.0.0.0', 0))]
 >>> for (af, socktype, proto, canonname, sa) in sockets:
...     s = socket.socket(af, socktype, proto)
...     s.bind(sa)
...     s.listen(5)
...     print s.getsockname()
...
('0.0.0.0', 53591, 0, 0)
('0.0.0.0', 53592)
 >>>

-bob




More information about the PEAK mailing list