Advertisement
Guest User

The Client

a guest
Jun 8th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # Sample Username Client Service Handler.
  2. from socket import *
  3. import threading
  4. import os
  5. import csv
  6.  
  7. Username = ("Owatch")
  8. # ^^ Change Username to make a new Client!!
  9.  
  10. host = input("Host: ")
  11. port = input("Port: ")
  12. try:
  13.  
  14. ss = socket(AF_INET,SOCK_STREAM)
  15. ss.connect((host,int(port)))
  16. except IOError:
  17. print("Console: Error Encountered During Username Accuasition")
  18.  
  19. ss.send(Username.encode())
  20. print("\n Username Sent...")
  21. while True:
  22. try:
  23. print("\nWaiting to Recieve Data")
  24. data = ss.recv(1024)
  25. if data:
  26. translated_data = data.decode()
  27. print(translated_data)
  28. if translated_data == Username:
  29. print("It's one of ours!")
  30.  
  31. else:
  32. Client_Username = translated_data
  33. print ("Foreign Username is set to be: ", Client_Username)
  34.  
  35.  
  36. except Exception as e:
  37. print (vars(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement