I have three files. client.py, server.py and test.py. client.py is below:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 6088))
while True:
a = raw_input()
s.send(a)
s.close()
server.py:
import socket
import sys
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1',6088))
s.listen(1)
print("Waitting for connection.....")
while True:
socket,addr = s.accept()
while True:
data = socket.recv(1024)
if data:
print(data)
s.close()
test.py:
while True:
a = raw_input()
print("welcom "+ a)
I use server.py
or test.py
to start the server, then I use the client.py
to start the client, but when I am inputting something in client, the server doesn't show anything. Why? And how to fix it.