On 6/17/05, Maurice LING <ma*********@acm.org> wrote:
Hi,
I'm writing something that specifies the use of SOAP. One requirement
that fumbles me is the port number(s) to use.
(I assume you're talking about TCP ports, not SOAP ports.)
Is there any way to find
out which ports are not used by the system?
Try binding to a port and you'll get an 'Address already in use error'
if it's occupied :)
I've looked in the library
reference and doesn't seems to get anything.
Is there a problem with say 2 programs using the same ports?
AFAIK, even the same process can't bind to the same port twice:
import socket
s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s1.bind(('localhost', 8000))
s2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s2.bind(('localhost', 8000))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 1, in bind
socket.error: (10048, 'Address already in use')
- kv