An Example Script To Connect To Google Using Socket
An Example Script To Connect To Google Using Socket
import socket
import sys
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Socket successfully created"
except socket.error as err:
print "socket creation failed with error %s" %(err)
try:
host_ip = socket.gethostbyname('www.google.com')
except socket.gaierror:
output:
Socket successfully created
the socket has successfully connected to google
on port == 173.194.40.19
Server :
Output :
# in the server.py terminal you will see
# this output:
Socket successfully created
socket binded to 12345
socket is listening
Got connection from ('127.0.0.1', 52617)