Skip to content

Instantly share code, notes, and snippets.

@adriaanbd
Created January 7, 2019 00:37
Show Gist options
  • Save adriaanbd/fe7832748c167a2f794692d000616fbb to your computer and use it in GitHub Desktop.
Save adriaanbd/fe7832748c167a2f794692d000616fbb to your computer and use it in GitHub Desktop.
sockets created by adriaanbd - https://repl.it/@adriaanbd/sockets
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = socket.gethostbyname('www.google.com')
print("Google's IP is: {}".format(ip))
# My hostname
me = socket.gethostname()
print("My hostname is: {}".format(me))
# And my ip
ip = socket.gethostbyname(me)
print("My IP Address is {}:".format(ip))
# My fully qualified hostname
fqdn = socket.getfqdn()
print("My fully qualified host name is {}:".format(fqdn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment