Пишу на питоне 3.2, тестирую на винде 7.
Вот код.
Сервер:
import socket
host = "localhost"
port = 44444
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(5)
sock, addr = s.accept()
while True:
buf = sock.recv(1024)
if buf == "exit":
sock.send("olol")
break
elif buf:
sock.send(buf)
sock.close()
import socket
import time
host = "localhost"
port = 44444
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
while True:
buf = input(">>")
s.send(buf)
result = s.recv(1024)
print(result)
if buf == "exit":
break
buff = 0
s.close()
time.sleep(10)