added sample test files in python and c++ for

linux socket testing
This commit is contained in:
2026-01-20 14:42:06 +05:30
parent 47c89dc2eb
commit 211f144521
3 changed files with 88 additions and 0 deletions

25
linux_socket_test.py Normal file
View File

@@ -0,0 +1,25 @@
import socket
import os
SOCKET_FILE = '/tmp/mysocket'
if os.path.exists(SOCKET_FILE):
os.remove(SOCKET_FILE)
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
server.bind(SOCKET_FILE)
server.listen(1)
print(f"Listening on {SOCKET_FILE}...")
try:
while True:
conn, _ = server.accept()
data = conn.recv(1024)
if data:
print("Received:", data.decode())
conn.sendall(data) # Echo back
conn.close()
finally:
server.close()
os.remove(SOCKET_FILE)