Wednesday, August 12, 2009

Python's Socket Module

Hey all of you Python enthusiasts!

I just wanted to share something I found today.

If you're trying to find an IP address on your network and you know the other computer's "name", then Python's socket module can help.

If in Windows:

1. Go to Run
2. Type "cmd"
3. Type "python" to start IDLE. (If you don't know what IDLE is click here to get more information.
4. Type "import socket"
5. Type "print socket.gethostbyname("xxx") (Where "xxx" is the machine's name)
6. If that host is found in your network, the host IP will show up on screen.

I came across this function while trying to set up an NFS server in my home network.

As of this posts writing, I have not been able to set up NFS.

Anyhow, that's all for now.

Until next time.

1 comment:

  1. WOW! This is solely interesting but when are YOU going to post the rest of AMBAR'S FAB PHOTOS?
    p.s. Great BLOG YOU have!!!

    ReplyDelete