Hello I need help to understand the basic concept of UDP sockets: I am trying to set up a point-to-point connection between host A(192.168.2.222:4000) and host B(192.168.2.224:4000)
I am opening the socket like this: ------------------------------------------------------------------ function UDP_trx.s_open(IP,PORT:string):boolean; begin udpsock:=TUDPBlockSocket.Create; udpsock.Bind('0.0.0.0',PORT); // bind socket to local NIC ? udpsock.Connect(IP,PORT); // connect socket to remote IP:PORT ? end; ----------------------------------------------------------------- I am sending one byte over the socket (do I need to connect for every SendByte?) ----------------------------------------------------------------- procedure UDP_trx.s_tx(txbyte:byte; IP,PORT:string); var i:integer; s:string; begin //udpsock.Connect(IP,PORT); // do I need to reconnect every time? udpsock.SendByte(txbyte); end; ----------------------------------------------------------------- And I am receiving one byte over the socket like this: ----------------------------------------------------------------- function UDP_trx.s_rx(var rxbyte:byte; IP,UDPPRT:string):boolean; var ipstr:string; prt:integer; begin if udpsock.WaitingDataEx=0 then begin result:=false; exit; end; rxbyte:=udpsock.RecvByte(1); //ipstr:=udpsock.GetRemoteSinIP; //prt:=udpsock.GetRemoteSinPort; //if (ipstr=IP) and (prt=StrToInt(UDPPRT)) then begin result:=true; exit; end; //filter for RemoteSin result:=true; end; ----------------------------------------------------------------- What I do not understand is this: Whenever I send a byte to any IP adress (even one that does not exist) I am receiving a byte at the remote end as long as the port is matching. Only when I use the s_rx filter with GetRemoteSinIP and GetRemoteSinPort I can be sure that I receive from the correct source IP. So I suppose that I have not really understood how to use BIND and CONNECT Thank you for help Mit freundlichem Gruß / Yours sincerely / Cordialement Christian Sporer Grüntenstr.18 80686 München Tel.: +(49) 89 54217952 Fax.: +(49) 89 52389119
_______________________________________________ synalist-public mailing list synalist-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synalist-public