Skip to content

Instantly share code, notes, and snippets.

@codeboy101
Last active January 10, 2016 15:13
Show Gist options
  • Select an option

  • Save codeboy101/8b7441014d4f8a659bca to your computer and use it in GitHub Desktop.

Select an option

Save codeboy101/8b7441014d4f8a659bca to your computer and use it in GitHub Desktop.
## explain the following code :
import socket
my_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host = 'www.google.com'
port = 80
remote_ip = socket.gethostbyname(host)
my_socket.connect((remote_ip,port))
print ('socket Connected to ' + host + ' on ip ' + remote_ip)
message = "GET / HTTP/1.1\r\n\r\n"
my_socket.sendall(message)
reply = my_socket.recv(4096)
print(reply)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment