Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Owatch's Multi-Threading Username Sever. (Because the select module can suck it)
- from socket import *
- import threading
- import os
- import csv
- import sys
- # Defining Important Information
- User_List = []
- Connections_List = []
- # Making a thread class for each connection recieved.
- class Client(threading.Thread):
- def __init__(self,conn):
- super(Client, self).__init__()
- self.conn = conn
- self.username = self.conn.recv(1024).decode()
- if not any(user.username == self.username for user in User_List):
- print("New guy")
- # Add new guy to the list
- User_List.append(self)
- # Get everyone's names
- current_userlist = [user.username for user in User_List]
- # Send everyone's names to everyone
- for x in User_List:
- conn.send(x.username.encode())
- U_HOST = input("Host: ")
- U_PORT = input("Port: ")
- SS = socket(AF_INET,SOCK_STREAM)
- SS.bind((U_HOST,int(U_PORT)))
- SS.listen(2)
- while True:
- Connection,Address = SS.accept()
- Connections_List.append(Address)
- print("Connection Taken, and address added to list")
- CX = Client(Connection)
- CX.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement