daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import socket
  2. import sys
  3. import time
  4. import threading
  5.  
  6. s = socket.socket()
  7. host = input(str("Please enter the hostname of the server : "))
  8. port = 8000
  9. s.connect((host,port))
  10. print(" Connected to chat server")
  11. def send_Messages():
  12.     while 1:
  13.         message = input(str(">>"))
  14.         message = message.encode()
  15.         s.send(message)
  16.         print("message has been sent...")
  17.         print("")
  18. def receive_Messages():
  19.     while True:
  20.         incoming_message = s.recv(1024)
  21.         incoming_message = incoming_message.decode()
  22.         print(" Server: ", incoming_message)
  23.         print("")
  24.  
  25. incoming_thread = threading.Thread(target=receive_Messages)
  26. incoming_thread.start()
  27. send_thread = threading.Thread(target=send_Messages)
  28. send_thread.start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top