Hello Angus, Settings the property do not produce the error, it's on .Connect/.Send that exception raise.
Regards. ARMSL> You don't need to send your reply from the event, just make Src a public ARMSL> variable associated with this specific socket, and use SendTo later. I ARMSL> think your issue is trying to set a property, rather than actually ARMSL> sending a packet. ARMSL> Angus ARMSL> -------- Original Message -------- ARMSL> *Subject:* Re: [twsocket] Force UDP source port when sending ARMSL> *From:* Dod <[EMAIL PROTECTED]> ARMSL> *To:* ICS support mailing <email@example.com> ARMSL> *Date:* Sat, 28 Jun 2008 18:06:32 +0200 ARMSL> Hello Angus, ARMSL> Thank you, so I cannot force the port to same as listening but if I do ARMSL> it within the OnDataAvailable then the .SendTo will automatically ARMSL> re-use the same socket to send data back using same src port whenever ARMSL> this port is actually used for listening by the server ? ARMSL> So this also mean that the OnDataAvailable procedure may take a while ARMSL> to get outside if I need to do lenghtly operation. Is there a way to ARMSL> "keep" this socket to re-use later ? ARMSL> regards. >>> So question is : how to force UDP port source when sending it whenever >>> this port is used by a listener socket as the other application do ? >>> May be thru sockaddr_in structure ? ARMSL>> Yes, this is the (simplified) code from the ICS SNTP Time Server ARMSL> that ARMSL>> responds to a UDP request with the time to the same IP and port. ARMSL>> http://www.magsys.co.uk/download/software/sntp.zip ARMSL>> Angus ARMSL>> procedure TTimeServ.WUDPSocketDataAvailable(Sender: TObject; ARMSL> Error: ARMSL>> Word); ARMSL>> var ARMSL>> Buffer : array [0..1023] of char; ARMSL>> Src : TSockAddrIn; ARMSL>> SrcLen : Integer; ARMSL>> NewTime : LongWord; ARMSL>> DataPtr : TWSocketData ; ARMSL>> begin ARMSL>> SrcLen := SizeOf(Src); ARMSL>> FWUDPSocket.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); ARMSL>> SrcIPAddr := Src ; ARMSL>> NewTime := Trunc ((GetUTCTime - 2) * 24 * 60 * 60) ; ARMSL>> ByteSwaps (@NewTime, SizeOf(NewTime)) ; ARMSL>> DataPtr := @NewTime ; ARMSL>> if FWUDPSocket.Sendto (Src, SrcLen, DataPtr, SizeOf(NewTime)) ARMSL> = ARMSL>> SOCKET_ERROR then ARMSL> TriggerQueryDone(FWUDPSocket.LastError); ARMSL>> end; ARMSL> -- ARMSL> To unsubscribe or change your settings for TWSocket mailing list ARMSL> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket ARMSL> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be