how to get any available port
Tue Oct 4 23:20:17 CEST 2005
Grant Edwards <grante at visi.com> writes:
> > In the nomenclature of some of these applications, that kind
> > of transfer is called a client to client connection. Both
> > ends are called clients.
> IIRC, we were talking about TCP sockets.
Yes, but if the person was talking about using TCPs sockets in a chat
application, they may have been using chat terminology rather than TCP
terminology. In a typical chat app, a zillion clients all talk
through TCP to a central server, which is like a phone switch. That
lets Alice connect to the server and immediately see if Bob is online
and what Bob's (possibly dynamic) IP address is. If Alice wants to
send Bob a file, she opens a TCP connection directly to Bob. That's
called a client to client connection because Alice and Bob are both
So, there's a reasonable application for wanting to open a listener
port without binding any specific port number. Alice would just ask
her OS to assign her a port (say it assigns 23789) and listen on it,
instead of having to contend with other apps on the same IP for some
specific port number. Then she'd send a message through the chat
server asking Bob to connect to port 23789 on her machine.
I'm not sure if there's a way to do this. Do you happen to know?
More information about the Python-list