> 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 ?
Yes, this is the (simplified) code from the ICS SNTP Time Server that responds to a UDP request with the time to the same IP and port. http://www.magsys.co.uk/download/software/sntp.zip Angus procedure TTimeServ.WUDPSocketDataAvailable(Sender: TObject; Error: Word); var Buffer : array [0..1023] of char; Src : TSockAddrIn; SrcLen : Integer; NewTime : LongWord; DataPtr : TWSocketData ; begin SrcLen := SizeOf(Src); FWUDPSocket.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); SrcIPAddr := Src ; NewTime := Trunc ((GetUTCTime - 2) * 24 * 60 * 60) ; ByteSwaps (@NewTime, SizeOf(NewTime)) ; DataPtr := @NewTime ; if FWUDPSocket.Sendto (Src, SrcLen, DataPtr, SizeOf(NewTime)) = SOCKET_ERROR then TriggerQueryDone(FWUDPSocket.LastError); end; -- 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
