From: Joel VanderWerf Date: 2009-07-09T01:35:28+09:00 Subject: Re: How to accept a varying amount of UDP packets using recvfrom Randy General wrote: > I'm currently creating an application that can query a game-server for > its status, total players, hostname, etc. I send out a challenge packet, > and in return I receive between 1 and 3 UDP packets. > > Is there an effective way to deal with receiving a varying amount of UDP > packets? If I do a recvfrom for two packets, the process will time out > if only a single packet arrives. > > Any assistance is appreciated! You need to specify how long to wait until you decide that no more packets will arrive. Can you guarantee that the packets will arrive within 500ms? Then make that your timeout. You can timeout socket reads with Kernel#select(), but you probably knew that. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407