[Twisted-Python] listenTCP(), tcp.Port()

Matthew Glubb matt at zgroupplc.com
Mon Apr 2 11:47:07 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi All,

I want to create a simple server that listens for data but I do not  
want to specify the port, I want the port to be automatically  
selected based on the currently available ports on the system. Is  
there any way to do this using Twisted?

Using PHP it is a simple matter of:

// Create a socket
$sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

// Get the port number used
@socket_getsockname($sock, $ip, $port);

Where $ip and $port are passed by reference and result in the values  
for the socket's ip address and port.

Looking at tcp.Port(), it doesn't seem like there is any provision  
for dynamically selecting an available port. Or am I missing something?

Regards,

Matt



m a t t h e w   g l u b b

________________________________________________________________________
Z Group PLC

Tel: +44 (0) 8700 111 173
Fax: +44 (0) 8707 051 393
Txt: +44 (0) 7800 140 877
Web: <http://www.zgroupplc.com/>

This  email  and  any  files  transmitted  with it are  confidential and
intended solely for the use of the individual or entity to whom they are
addressed.  The opinions  expressed in this mail are those of the author
and do not necessarily  represent the views of the company.  If you have
received this email in error please notify <service at zgroupplc.com>



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFGESWCyI6MkdKPngkRAjXyAJ9Yd9o/vWeYG9PhB1NbphbGgN2quwCdHRDh
DqF0IRAxqhcKLoKMeH+Ebwg=
=8qwC
-----END PGP SIGNATURE-----




More information about the Twisted-Python mailing list