fork download
  1.  
  2. import socket
  3. import sys
  4.  
  5. try:
  6. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. print ("Socket successfully created")
  8. except socket.error as err:
  9. print ("socket creation failed with error %s" %(err))
  10. port = 80
  11. try:
  12. host_ip = socket.gethostbyname('www.google.com')
  13. except socket.gaierror:
  14. print ("there was an error resolving the host")
  15. sys.exit()
  16. s.connect((host_ip, port))
  17. print ("the socket has successfully connected to google")
  18.  
Success #stdin #stdout 0.02s 9312KB
stdin
Standard input is empty
stdout
Socket successfully created
there was an error resolving the host