For now I try to find a solution for sending more than one UDP-packet to a single port during the server is doing some other stuff. Because at the moment if the client will send two or more UDP-packets to the server during his doing_some_stuff()-execution, the server will only be able to get the first received packet with s.recv(bufsize) - if I call the s.recv(bufsize) a second time, it will return b''.
Code: Select all
>>> import network >>> import socket >>> ap_if = network.WLAN(network.AP_IF) >>> ap_if.active(True) >>> s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) >>> s.bind(("<IP_OF_SERVER>",<SOME_PORT>) >>> doing_some_stuff() #calling a function here, which will need some time to execute! #During doing_some_stuff() a connected client is sending a UDP-packet to the socket (s), with socket.sendto() #after finishing doing_some_stuff() it is possible to call s.recv(bufsize), for receiving the UDP-packet which was sent during doing_some_stuff()! >>> s.recv(1024) b"someData" #received data
Is it possible to receive more the one UDP-packet - how?
(one solution will be, that the server use more than one socket, with another port - and the client will send the next packet to the next socket and port - but is it possible to use the same socket?)