Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TIdUDPBase::Broadcast method



Permlink Replies: 4 - Last Post: Jun 28, 2017 11:35 PM Last Post By: Arkady Semylio Threads: [ Previous | Next ]
Arkady Semylio

Posts: 9
Registered: 5/25/17
TIdUDPBase::Broadcast method
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2017 9:00 AM
Hi all.

I'm sorry in advance for this stupid question, but I can't realize the meaning of the third parameter (AIP) in TIdUDPBase::Broadcast method:

	void __fastcall Broadcast(const Idglobal::TIdBytes AData, const System::Word APort, const System::UnicodeString AIP = System::UnicodeString())/* overload */;


Maybe it permits to specify a particular interface? So, what's the IP to use? The subnet address? I'm sorry, but I can't find anything about that parameter in the Indy's offline docs.

Bye bye
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TIdUDPBase::Broadcast method
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2017 1:18 PM   in response to: Arkady Semylio in response to: Arkady Semylio
Arkady Semylio wrote:

I can't realize the meaning of the third parameter (AIP) in
TIdUDPBase::Broadcast method:

	void __fastcall Broadcast(const Idglobal::TIdBytes AData, const
System::Word APort, const System::UnicodeString AIP =
System::UnicodeString())/* overload */; 

It is the target IPv4 address that you want to send the broadcast to.
If you do not specify an IP address, "255.255.255.255" is used by
default.

Note that Broadcast() only works in IPv4. IPv6 does not support UDP
broadcasting, you have to use IP multicasting instead (see
TIdIPMCastClient and TIdIPMCastServer).

Maybe it permits to specify a particular interface?

Not an interface, no. It is to specify the target broadcast IP
address. The broadcast will go over whatever interface that TIdUDPBase
is locally bound to (see TIdUDPClient.BoundIP or
TIdUDPServer.Bindings[0].IP).

--
Remy Lebeau (TeamB)
Arkady Semylio

Posts: 9
Registered: 5/25/17
Re: TIdUDPBase::Broadcast method
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2017 3:36 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Arkady Semylio wrote:

Note that Broadcast() only works in IPv4. IPv6 does not support UDP
broadcasting, you have to use IP multicasting instead (see
TIdIPMCastClient and TIdIPMCastServer).

Thanks. Yes, only IPv4. No, IPv6 is not supported by IoT devices I have to use.

Not an interface, no. It is to specify the target broadcast IP
address. The broadcast will go over whatever interface that TIdUDPBase
is locally bound to (see TIdUDPClient.BoundIP or
TIdUDPServer.Bindings[0].IP).

Ah, ok. Good to know. Now it's clear to me that I've to calculate the broadcast address
from netmask's ones' complement for a specific subnet.

Thank you.

Bye bye
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TIdUDPBase::Broadcast method
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2017 4:02 PM   in response to: Arkady Semylio in response to: Arkady Semylio
Arkady Semylio wrote:

Ah, ok. Good to know. Now it's clear to me that I've to calculate the
broadcast address from netmask's ones' complement for a specific
subnet.

If you want to use a subnet-specific broadcast IP, yes:

broadcastIP = (interfaceIP and netmask) or (not netmask)

Depending on what platform(s) your app runs on, there may be platform
APIs to retreive the broadcast IP from the OS, such as getifaddrs() on
*Nix systems, or WSAIoctl(SIO_GET_INTERFACE_LIST) on Windows.

--
Remy Lebeau (TeamB)
Arkady Semylio

Posts: 9
Registered: 5/25/17
Re: TIdUDPBase::Broadcast method
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 28, 2017 11:35 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

broadcastIP = (interfaceIP and netmask) or (not netmask)

Ok. Thank you for the confirmation.

Bye bye

Edited by: Arkady Semylio on Jun 28, 2017 11:35 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02