Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Sample Username Client Service Handler.
- from socket import *
- import threading
- import os
- import csv
- Username = ("Owatch")
- # ^^ Change Username to make a new Client!!
- host = input("Host: ")
- port = input("Port: ")
- try:
- ss = socket(AF_INET,SOCK_STREAM)
- ss.connect((host,int(port)))
- except IOError:
- print("Console: Error Encountered During Username Accuasition")
- ss.send(Username.encode())
- print("\n Username Sent...")
- while True:
- try:
- print("\nWaiting to Recieve Data")
- data = ss.recv(1024)
- if data:
- translated_data = data.decode()
- print(translated_data)
- if translated_data == Username:
- print("It's one of ours!")
- else:
- Client_Username = translated_data
- print ("Foreign Username is set to be: ", Client_Username)
- except Exception as e:
- print (vars(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement