This repository has been archived on 2025-07-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fsad/network-test/main.py
AKP bafce3855f
Alter 3 files
Add `Client.java`
Add `Server.java`
Add `main.py`
2023-03-02 15:32:43 +00:00

18 lines
514 B
Python

import socket
import sys
HOST = "0.0.0.0" # Standard loopback interface address (localhost)
PORT = int(sys.argv[1]) # Port to listen on (non-privileged ports are > 1023)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
while True:
conn, addr = s.accept()
print(f"CONN {addr}")
data = conn.recv(1024)
print(f"RECV {repr(data.decode())}")
conn.sendall(b"got it fucko\n")
conn.close()
print("CLOS")