Advertisement
waterlgndx

Asynchronous Chat Server Python3.4.1

Sep 21st, 2014
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. ##Asynchronous Chat Server
  2. ##Waterlgndx
  3.  
  4. ##Chat Server Code based on the first 2 youtube videos posted by SolidShellSecurity :
  5. ##    https://www.youtube.com/watch?v=qELZAi4yra8
  6. ##    https://www.youtube.com/watch?v=Dip7_U12_uU
  7.  
  8. ## I'm using Python3.4.1 on Windows 7.
  9. from socket import *
  10.  
  11. HOST = 'localhost'              #in order to get the client to work host had to be filled in,
  12.                                 #    this is here for consistency
  13. PORT = 6014
  14. s = socket(AF_INET, SOCK_STREAM)
  15. s.bind((HOST, PORT))
  16. s.listen(1)
  17. conn, addr = s.accept()
  18. while True:
  19.     data = conn.recv(1024)
  20.     print("Received ", data.decode('UTF-8'))
  21.     reply = input("Reply:" )
  22.     conn.sendall(bytes(reply, 'UTF-8'))
  23. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement