-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
34 lines (26 loc) · 907 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import socket
import threading
HOST = '192.168.1.1' # replace with actual client IP
PORT = 13337
def handle_client(client_socket):
while True:
data = client_socket.recv(1024).decode('utf-8')
if not data:
break
print("Person A:", data)
response = input("Enter your response: ")
client_socket.send(bytes(response, 'utf-8'))
client_socket.close()
def main():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((HOST, PORT))
server.listen(5)
print(f"[*] Listening on {HOST}:{PORT}")
while True:
client, addr = server.accept()
print(f"[*] Accepted connection from {addr[0]}:{addr[1]}")
client_handler = threading.Thread(target=handle_client,
args=(client,))
client_handler.start()
if __name__ == "__main__":
main()