#! /usr/bin/env python3
import socket, threading 

IP = '0.0.0.0'
PORT = 9998

def main():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.bind((IP, PORT))
    server.listen(5)
    print('[*] Listing on {IP}:{PORT}'.format(IP=IP, PORT=PORT))
    while True:
        client, address = server.accept()
        print('[*] Accept connection from {address1}:{address2}'.format(address1=address[0], address2=address[1]))
        client_handler = threading.Thread(target=handle_client, args=(client,))
        client_handler.start()

def handle_client(client_socket):
    with client_socket as sock: 
        request = sock.recv(1024)
        print(f'[*] Received: {request.decode("utf-8")}')
        sock.send(b'ACK')

if __name__ == "__main__":
    main()
