Jun-16-2020, 11:17 PM
I have a program in a loop.
how to add data transmission via socket in a loop without blocking the loop itself.
and automatically retrieve data from the port if there is data transmission from the client (maybe an event-driven concept)
code :
how to add data transmission via socket in a loop without blocking the loop itself.
and automatically retrieve data from the port if there is data transmission from the client (maybe an event-driven concept)
code :
bind_port = 1234
# create as a server
def myloop ():
global dataRX
loopx=1
while loopx < 10000:
dataTX = process (DataRX)
sock.send(dataTX) #send dataTX via port
loopx = loopx + 1
def receive ():
#automatically retrieve data from client
DataRX = sock.recv() # get data from client
process (param):
... code process ...Thank You
