Hello Wilfried, thank you for your help. I've changed my code but the problem persists. Internally RecvFrom is
Result := DoRecvFrom(FHSocket, Buffer^, BufferSize, 0, From, FromLen); if Result < 0 then FLastError := WSocket_Synchronized_WSAGetLastError else FReadCount := FReadCount + Result; Result is -1 and FLastError is 10014. And the event OnDataAvailable is triggered infinitely. In ICS Faq this error code is WSAEFAULT 10014 Bad address. Why it works fine with Receive but not with ReceiveFrom? There is another way to obtain the IP source? My new OnDataAvailable code is { int rec, FromIPLen; TSockAddrIn FromIP; char block[TAM_BUFFER]; //TAM_BUFFER 8192 std::string frame; if (Error == 0) { rec = server->ReceiveFrom(block, sizeof(block), FromIP, FromIPLen); //rec = server->Receive(block, sizeof(block)); if(rec > 0) { frame.assign(block, rec); LOGIN("Received PORT:%s, %d.", frame.c_str(), rec); } } } Thanks for all help. -----Mensaje original----- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] nombre de Wilfried Mestdagh Enviado el: jueves, 13 de septiembre de 2007 13:18 Para: ICS support mailing Asunto: Re: [twsocket] UDP ReceiveFrom error Hello Lorenzo, You only can call Receive or ReceiveFrom 1 time in OnDataAvailable. Don't loop in it as in your example. This could be the trouble. If you don't have received all available data then OnDataAvailable will fire again and there you receive the rest. However with UDP packet bounds are preserved, so you will receive the whole packet at once. Be sure your receiving buffer is large enough. The MultiThreaded is nececary yes. Also be sure you create and destroy TWSocket in the Execute method of the thread. If you do not you have a false thread wich can also cause troubles. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be