Hello all, I'm trying to create application that would run on multiple machines. This application has to know IP addresses of all other machines running same software. I'm trying to do something like discovery on network. Protocol I decided to use for discovery is UDP. On mailing list I already saw, that only one TWSocket component can be used for receiving and sending data. So, I wrote following code for listening:
UDPSocket.Proto :='udp'; UDPSocket.Addr :='0.0.0.0'; UDPSocket.Port :='1234'; UDPSocket.Listen; Timer1.Enabled :=True; and on timer event there is code for sending broadcast data to notofy others about existence: procedure TForm1.Timer1Timer(Sender: TObject); var SendTo:TSockAddrIn; LenSendTo:integer; Data:string; begin LenSendTo:=SizeOf(SendTo); Data:='Test'+#0; SendTo.sin_port :=htons(1234); SendTo.sin_addr :=StrToInAddr('255.255.255.255'); SendTo.sin_family :=AF_INET; UDPSocket.SendTo(SendTo,LenSendTo,@Data[1],Length(Data)); end; StrToInAddr is function that I found in mailing list. On receive even I have code from udplistener sample: var Buffer : array [0..1023] of char; Len : Integer; Src : TSockAddrIn; SrcLen : Integer; begin SrcLen := SizeOf(Src); Len := WSocket.ReceiveFrom(@Buffer, SizeOf(Buffer), Src, SrcLen); if Len >= 0 then begin Buffer[Len] := #0; listbox1.Items.Add(StrPas(Buffer)); end; end; Problem is that sending is ok (no error), but ondataavaliable event never gets fired, so I'm assuming that nothing is sent. What am I doing wrong. P.S. I have been using ICS for awhile now and I think that this is most stable component suite for networking. Keep the good work. Regards, Skok Tone -- 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