information needed to make a connection between computers

Tim Williams (gmail) tdwdotnet at gmail.com
Sun Dec 11 14:25:46 EST 2005


On 11/12/05, John Walton <westside_indie at yahoo.com> wrote:
>
>  Hello again! I'm still working on that instant messenger (for science
> fair), and I have been reading about networking in some Java tutorials. In
> one part of it, it said to have a connection with another computer, you need
> to know the IP name of the computer you want to connect with. I don't know
> whether or not this is the same for Python, but could someone please tell me
> what information of the computer you want to connect with the you actually
> need for a connection? In other words (or plain english), what information
> do I need to get a connection with another computer (IP address, name, IP
> name)? Also, could you tell me how to find it on a computer? Since I'll be
> testing the instant messenger on the three computers in my house, I just
> need to know how to find the information on the computer I'd currently be on
> (not from any remote location). Thanks!  :)
>


You need to know the hostname of the remote machine you are trying to make a
connection to.    From this you can work out the IP address of the machine
and then connect to it directly.    You could work with just the IP address,
but these are liable to change, where as the hostname in theory won't.

>>> import socket
>>> socket.gethostbyname('www.yahoo.com')
'216.109.117.207'
>>>

If the machine is on your network,  using its name (eg 'JohnW'   )  should
give the same result

HTH :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051211/3c80f4f2/attachment.html>


More information about the Python-list mailing list