iPhone UDP-broadcast-und-Antwort

Brauche ich zum versenden eines UDP-broadcast von einem iPhone, und hören Sie dann eine UDP-Antwort mit einem timeout-Zeitraum. Ich fand Apple UDPEcho Beispiel aber ich bin nicht sicher, ob es ist, was ich brauche. Auch fand dieses Beispiel zu senden, aber nicht empfangen. Im Grunde, ich muss etwas tun, so einfach ist das:

//send the broadcast
SendUDP("255.255.255.255", targetPort, myData);
//A blocking call to get the data.  Timeout value will be short, 2 seconds at most
//An asynchronous option is ok, if it's necessary.
Response = GetFirstUDPResponse(receptionPort, timeoutValue);

//process the response
if(Response == null)
  //we timed out
else
  //process response

Ich bin der Hoffnung für eine einfache Lösung, wo ich nicht haben, das Rad neu zu erfinden. Ich schätzen jede Beratung über die beste Strategie, um diese umzusetzen!

InformationsquelleAutor Alex | 2011-10-03
Schreibe einen Kommentar