import socket

class SockerServer:
    
    HOST = ""
    PORT = 8000

    def __init__(self):
        pass

    def serv(self):
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv_sock:
            serv_sock.bind((self.HOST, self.PORT))
            serv_sock.listen(1)
            print("Server started")
            print("Waiting for connection...")
            sock, addr = serv_sock.accept()

            with sock:
                print("Connected by", addr)
                while True:
                    data = sock.recv(1024)
                    print(f"Received: {data} from: {addr}")
                    if not data:
                        break
                    if data == b'close':
                        break
                    data = data.upper()
                    print(f"Send: {data} to: {addr}")
                    sock.sendall(data)
                print("Disconnected by", addr)

def main():
    server = SockerServer()
    while True:
        server.serv()

if __name__ == "__main__":
    main()