Hi, I need that my server will be in waiting mode while first packet arrived, when it happens it shoud start to receive packets until the socket.settimeout(1) function kill waiting. my code seems like that, and is working properly until settimeout() return :
Traceback (most recent call last):
File "C:\Documents and Settings\Shatt\Desktop\SERVERIS1.txt", line 23, in <module>
paketas= s.recv( 2500 )
timeout: timed out
the main problem is that i need that my program execute other commands after while cycle, maybe any suggestions how to make it?
s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) s.bind( ( HOST, PORT ) ) if s.recv (2500): while 1: f = open(.....) paketas= s.recv( 2500 ) s.settimeout(1) t_pak=datetime.datetime.now() a=t_pak.strftime('%Y-%m-%d %H:%M:%S.%f') f.write(....) f.close()
in short, i need that my server will wait until it get first packet, after this it shoud wait and receive all packets, and when server don't get packets for abaout 2sec, it should leave waiting mode, and other part of program should be executable.THANKS Very appreciate all suggestions.