Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UDP broadcast message fails
#3
(07-18-2019, 03:49 AM)Boba TC Wrote: IdUDPClient1->Broadcast( "This is a test. Ignore it.", 45242 );

When the Button1 is clicked - nothing visible happens.

You are not specifying an IP address to broadcast to, so it will default to "255.255.255.255", which is not really a good choice to broadcast to, as some routers/firewalls block it.  You really should be broadcasting to an actual subnet broadcast IP instead.

For instance, if your computer is assigned an IP of 192.168.0.5 with a subnet mask of 255.2255.255.0, then the subnet broadcast IP is 192.168.0.255.

If you look at the source code for TIdSocketHandle.Broadcast() in IdSocketHandle.pas, there is the following TODO comment:

Code:
if LIP = '' then begin
  if IPVersion = Id_IPv4 then begin
    // TODO: on Windows, use WSAIoctl(SIO_GET_BROADCAST_ADDRESS) instead.
    // On other platforms, use getifaddrs() or other suitable API to retreive
    // the broadcast IP if possible, or else the local IP/Subnet and then
    // calculate the broadcast IP manually...
    LIP := '255.255.255.255'; {Do not Localize}

If you don't use a platform-specific API to get the subnet broadcast IP, you can calculate it manually by getting the local IPv4 address and subnet mask (such as via GStack.GetLocalAddressList()), and then AND the IP with the mask, and then OR the result with the inverse of the mask.  The TIdIPAddress class can be used to parse the IP and mask strings into binary integers, and then to convert the result of the calculation back into an IP string.

(07-18-2019, 03:49 AM)Boba TC Wrote: I look at the WireShark dump but I have no idea what is going on (see attached).

There is no attachment present.

(07-18-2019, 05:51 PM)Boba TC Wrote: is my attachment there? can't see it. where is it?

Looks like you did not actually attach it.

Reply


Messages In This Thread
UDP broadcast message fails - by Boba TC - 07-18-2019, 03:49 AM
RE: UDP broadcast message fails - by Boba TC - 07-18-2019, 05:51 PM
RE: UDP broadcast message fails - by rlebeau - 07-18-2019, 10:22 PM
RE: UDP broadcast message fails - by Boba TC - 07-19-2019, 02:26 AM
RE: UDP broadcast message fails - by rlebeau - 07-19-2019, 09:55 PM
RE: UDP broadcast message fails - by Boba TC - 07-20-2019, 02:08 AM
RE: UDP broadcast message fails - by Boba TC - 08-17-2019, 04:35 AM
RE: UDP broadcast message fails - by rlebeau - 08-17-2019, 07:22 AM
RE: UDP broadcast message fails - by Boba TC - 07-20-2019, 08:09 PM
RE: UDP broadcast message fails - by rlebeau - 07-23-2019, 09:35 PM
RE: UDP broadcast message fails - by Boba TC - 08-22-2019, 12:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)