Python Forum
Sending/Receiving Multiple Message from Server or Client
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending/Receiving Multiple Message from Server or Client
#1
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...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,277 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  sending packet onto dummy network device but receiving echo sabuzaki 2 1,412 Feb-12-2023, 10:31 AM
Last Post: Vadanane
  Client/Server proper finalizing transfer wolfman5874 1 1,422 Jul-04-2022, 07:35 PM
Last Post: wolfman5874
Bug Problem connecting TLS client written in C++ and Twisted server gpropf 0 1,361 Jun-12-2022, 05:57 PM
Last Post: gpropf
  Server/client basic communication ebolisa 0 2,009 Sep-30-2021, 12:22 PM
Last Post: ebolisa
  Client server Multithreading Anan 6 5,754 Apr-21-2021, 08:19 PM
Last Post: SheeppOSU
Question Trouble with Client/Server reverse Shell! Gilush 0 2,757 Feb-03-2021, 01:04 PM
Last Post: Gilush
  Basic client server code question swisscheese 4 3,192 Dec-12-2020, 08:51 AM
Last Post: Larz60+
  How can i create a server for already existing client using Python? Chapanson 21 7,316 Aug-19-2020, 09:12 AM
Last Post: DeaD_EyE
  Simple TCP Client and TCP Server Problem Vapulabis 5 4,335 Jul-12-2020, 05:09 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020