Advertisement
Guest User

ravel asu

a guest
Feb 18th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import socket                           #line 1: Import socket module
  2.  
  3. s = socket.socket()                     #line 2: create a socket object
  4. host = socket.gethostname()             #line 3: Get current machine name
  5. port = 9999                             #line 4: Get port number for connection
  6.  
  7. s.bind((host,port))                     #line 5: bind with the address
  8.  
  9. print "Waiting for connection..."  
  10. s.listen(5)                             #line 6: listen for connections
  11.  
  12. while True:
  13.     conn,addr = s.accept()              #line 7: connect and accept from client
  14.     print 'Got Connection from', addr
  15.     conn.send('Server Saying Hi')
  16.     conn.close()                        #line 8: Close the connection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement