Hi guys,
Have the following PC config:
NIC1: 192.168.81.15 / 255.255.255.0
NIC2: 10.0.0.1 / 255.255.255.0
Want to do:
Want to send UDP broadcast packet to dest. addr. 255.255.255.255 from
specified IP address on the PC (for example from 192.168.81.15 to
255.255.255.255)
Problem:
UDP broadcast packet doubles to:
1. source 192.168.81.15, dest. 255.255.255.255 sent via NIC1
2. source 192.168.81.15, dest. 255.255.255.255 sent via NIC2
So, recipients in 10.0.0.0 network receive broadcast packets with from
FROM Ip address is 192.168.81.15 !
10.0.0.0 network's machines get IP using: ip:= sock.GetRemoteSinIP;
How I use sockets:
TUDPClient = class(TThread)
.......
CSock: TUDPBlockSocket;
.................
constructor TUDPClient.Create;
begin
..................
CSock:= TUDPBlockSocket.Create;
CSock.Bind(192.168.81.15,'0');
CSock.EnableBroadcast(true);
......
end;
procedure TUDPClient.Execute;
begin
...................
CSock.Connect ('255.255.255.255', '11111');
CSock.SendBuffer(PChar(LocData),Length(LocData));
......
//LocData is a string that I want to send.
end;
Why UDP packet been bound to specified IP, sends both to 192.168.81.0
and 10.0.0.0 networks with the SAME SOURCE IP address (192.168.81.15)
?
I need to send the UDP broadcast packets bounded to each IP on the PC
to 255.255.255.255
I imagine it should be like this:
CSockBind: array of TUDPBlockSocket;
constructor TUDPClient.Create;
begin
//getting all IPs of current PC to IPsToBind stringlist
LocalIPsCount:= IPsToBind.Count;
SetLength(CSockBind,LocalIPsCount);
for i:= 0 to LocalIPsCount-1 do
begin
CSockBind[i]:= TUDPBlockSocket.Create;
CSockBind[i].Bind(IPsToBind[i],'0');
CSockBind[i].EnableBroadcast(true);
end;
end;
procedure TUDPClient.Execute;
begin
.............
//send packets
for i:= 0 to LocalIPsCount-1 do
begin
if terminated then break;
CSockBind[i].Connect('255.255.255.255', '11111');
CSockBind[i].SendBuffer(PChar(LocData),Length(LocData));
sleep(1);
end;
.............
end;
I.e I thought that
- CSockBind[1] sends packet to 255.255.255.255 from source
192.168.81.15 via NIC1 to 192.168.81.0 network
- CSockBind[2] sends packet to 255.255.255.255 from source 10.0.0.1
via NIC2 to 10.0.0.0 network
But I does not work....every packet doubles on each NIC and sent to
bott (192... and 10...) networks with source IP 192.168.81.15 (!!!!)
Where I'm wrong?
Thanks alot.
--
Sergei
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public