Using TCP/IP

Paul Clinch pclinch at internet-glue.co.uk
Thu Oct 2 16:52:48 EDT 2003


jblazi <jblazi at hotmail.com> wrote in message news:<pan.2003.10.02.14.10.07.657000 at hotmail.com>...
> On Wed, 01 Oct 2003 13:34:05 -0400, Peter Hansen wrote:
> 
> > jblazi wrote:
> >> 
> >> How do I find out my own IP number (using Pythoi of course). And how do I
> >> send/receive data to/from andother TCP/IP socket (of known ip number)?
> > 
> > A computer can have more than one IP address.  How do you want
> > to deal with the situation where there are multiple interfaces
> > with different addresses?
> > 
> > Or is this just for personal code?  In which case, please specify the
> > OS on which you plan to run it.
> 
> Thx!
> 
> It should run on MSW, probably XP. I am teaching a computer class at high
> school this year and of course we are using Python. (In my view, Python is
> the most wonderful Lisp which has ever existed and I am a bit sorry that
> the Lisp features of Python seem to become deprecated!)
> 
> First I wanted to write my own course but the official
> tutorial is virtually perfect. The first program we shall write is a
> mastermind program and it would be nice if my pupils could play that over
> the internet too. The first point is that they have not permanent ip
> numbers so the ip number has to be found out first.
> 
> Janos Blazi
> 
> 
> ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
> http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
> ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


You can use other socket module calls to get further info. eg.

>>> socket.gethostbyname_ex('')
('homebrew', [], ['198.192.192.2', '192.168.1.2', '192.168.1.4'])

giving you a tuple includeing a list of interface addresses on your machine.

Paul Clinch




More information about the Python-list mailing list