I have a problem that I cannot solve alone:
I have a setup of two hosts in a LAN with the following parameters:
- Host A (192.168.2.25) is listening to UDP datagrams on port
18002. No other host is sending datagrams on this socket. So it's supposed
that Host A should should not receive anything.
- Host B (192.168.2.202) is sending an RTP stream on port 18001 to
Host A. I have no knowledge about the streaming SW as it is a ready made
module. It should be said that on Host A these datagrams are not handled,
i.e. there is no module that takes care oft he incoming datagrams!
On Host A (192.168.2.25:18002) I run the following simple code:
____________________________________________
var udprx:TUDPBlockSocket;
s:string; rx:byte; p:integer;
begin
udprx:=TUDPBlocksocket.Create;
udprx.Bind('0.0.0.0','18002');
repeat
if udprx.WaitingDataEx>0 then begin
rx:=udprx.RecvByte(1);
s:=udprx.GetRemoteSinIp;
p:=udprx.GetRemoteSinPort;
end;
until false;
end.
___________________________________________
When I debug the code on Host A, I can see that it enters into the portion
after "if udprx.WaitingDataEx>0. even as no other Host should be sending on
this port.
And when I check the values of ( s:=udprx.GetRemoteSinIp;
p:=udprx.GetRemoteSinPort; ) I can see that datagrams from Host B with Port
number 15551 are received on Host A.
How ist that possible?
My understanding of sockets is, that they are unique. How can datagrams from
socket 192.168.2.202:15551 be received on 192.168.2.25:18002 ?
Step2: I tried to modyfy the port numbers, i.e. instead of port 18001 for
the RTP from Host B I used 19000, and for receiving on Host A I used 19001.
The result is still the same!
Step3: Last try, I use 19000 for RTP and 19002 for receiving on Host A I
used 19002. Now everything seems ok., Host A is not receiving any more
datagrams.
Have I missed some basics on UDP/IP?
My second question, if you allow:
If I replace the sample code above on Host_A with this (Connect instead of
Bind), can I be sure that only datagrams from HOST_B are receiced from the
socket?
_______________________
var udprx:TUDPBlockSocket; //for host A
s:string; rx:byte; p:integer;
begin
udprx:=TUDPBlocksocket.Create;
udprx.Connect(IP_HOST_B,'18002');
repeat
if udprx.WaitingDataEx>0 then begin
rx:=udprx.RecvByte(1);
s:=udprx.GetRemoteSinIp;
p:=udprx.GetRemoteSinPort;
end;
until false;
end.
________________________
Friendly
Chris
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public