Sending/Receiving Multiple Message from Server or Client - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: Sending/Receiving Multiple Message from Server or Client (/thread-11883.html) |
Sending/Receiving Multiple Message from Server or Client - Lyperion - Jul-30-2018 Hi, my problem is that I don't know how I can send two times send and receive message from client to server. I've coded these; Example # Server Side ip="" port=8888 buffersize=1024 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((myIP, myPort)) s.listen(1) (cl, adress) = s.accept() cl.send("hi!".encoded()) msg=cl.recv(bufferSize).decode() msg=msg[0] print(" Received message is '{}'".format(msg)) # Client Side ip="" port=8888 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(ip,port) msg=s.recv(1024).decode() print(" {} ".format(msg)) #sending to server s.send("OK!".encode())This codes work well. They can communicate with each other. But, I want to send second message and I want to receive second message in a loop. How can we coded this? Best Regard... |