Using TCP/IP

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Mon Sep 29 19:09:15 EDT 2003


On Mon, 29 Sep 2003 21:19:26 +0200, rumours say that jblazi
<jblazi at hotmail.com> might have written:

>How do I find out my own IP number (using Pythoi of course).

One way that works on most systems is:

import socket
socket.gethostbyname(socket.gethostname())

Basically, this way you request the IP address for your host name; so
you depend on many variables: your system has a name that can be
resolved locally by a file or DNS lookup or similar...

>And how do I
>send/receive data to/from andother TCP/IP socket (of known ip number)?

>I mean: which module do I have to use for that?

The socket module.  Check the socket.socket class.
-- 
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.




More information about the Python-list mailing list