These are chat archives for IndySockets/Indy

2nd
Jun 2017
DelphiWorlds
@DelphiWorlds
Jun 02 2017 04:12
I have an application that "advertises" itself by way of a UDP broadcast.. if I call Broadcast on TIdUDPClient, is it supposed to broadcast on all bindable IP addresses, or does it just pick the first one, or something else? Is using UDP an advisable way of doing this in the first place? I note that for IPv6 networks I'll have to use multicast anyway
Note that the comms is (for now) just happening on the local network
DelphiWorlds
@DelphiWorlds
Jun 02 2017 06:43
I think I might need TIdIPMCastClient/Server.. just need to work out how to use them
DelphiWorlds
@DelphiWorlds
Jun 02 2017 08:23
I'm attempting to bind all local addresses to the TIdIPMCastClient, but it fails with socket error 10049
Not sure what value I should be putting for MulticastGroup in the server, either
DelphiWorlds
@DelphiWorlds
Jun 02 2017 08:33
ok.. that error happens on iOS Simulator.. not on Win32
DelphiWorlds
@DelphiWorlds
Jun 02 2017 09:16
...and also errors on iOS
Remy Lebeau
@rlebeau
Jun 02 2017 16:22
@DelphiWorlds Sending a UDP broadcast will go out on a single IP interface of the OS's choosing, unless you bind the socket to a specific interface beforehand, or use the broadcast IP of a specific subnet rather than the generic 255.255.255.255 broadcast address. If you want to broadcast on all available interfaces, you have to send a broadcast to each one individually.
Remy Lebeau
@rlebeau
Jun 02 2017 16:28
@DelphiWorlds I can't comment on your 10049 error without seeing how you are binding the IPs to begin with. The MulticastGroup is the network multicast IP address that you want to send/receive packets on (the IP that routers watch for on packets), which is different than the local IP address that you bind sockets to. IPv4 multicast group addresses are in the 224.x.x.x to 239.x.x.x range. IPv6 multicast group addresses are in the FF0x:x:x:x:x:x:x:x range
DelphiWorlds
@DelphiWorlds
Jun 02 2017 22:04
I'm not going beyond the router, so I assume I won't need multicast? I just need to make sure the broadcast is seen through the correct connection..
I need to loop through the available IPs and send on each
DelphiWorlds
@DelphiWorlds
Jun 02 2017 22:53
ok.. I need multicast because IPv6 is involved
procedure TNetworkingModel.ConfigureUDPBindings(const AListener: TIdIPMCastClient);
var
LHandle: TIdSocketHandle;
I: Integer;
begin
AListener.Bindings.Clear;
for I := 0 to FLocalAddresses.Count - 1 do
begin
LHandle := AListener.Bindings.Add;
LHandle.IPVersion := FLocalAddresses.Addresses[I].IPVersion;
LHandle.IP := FLocalAddresses.Addresses[I].IPAddress;
LHandle.Port := AListener.DefaultPort;
end;
end;
oops
not that good with gitter
procedure TNetworkingModel.ConfigureUDPBindings(const AListener: TIdIPMCastClient);
var
  LHandle: TIdSocketHandle;
  I: Integer;
begin
  AListener.Bindings.Clear;
  for I := 0 to FLocalAddresses.Count - 1 do
  begin
    LHandle := AListener.Bindings.Add;
    LHandle.IPVersion := FLocalAddresses.Addresses[I].IPVersion;
    LHandle.IP := FLocalAddresses.Addresses[I].IPAddress;
    LHandle.Port := AListener.DefaultPort;
  end;
end;
that's how I'm configuring the bindings
DelphiWorlds
@DelphiWorlds
Jun 02 2017 23:00
if I don't attempt to bind the IPv6 addresses, no error
DelphiWorlds
@DelphiWorlds
Jun 02 2017 23:11
TIdIPMCastServer also errors if attempting a Send on an IPv6 address

Debugger Exception Notification

Project dyld_sim raised exception class EIdSocketError with message 'Socket Error # 49

Cannot assign requested address.'.

Break Continue Help

DelphiWorlds
@DelphiWorlds
Jun 02 2017 23:35
even if I ignore the IPv6 addresses, my client (192.168.56.100) doesn't receive a broadcast from the server (192.168.56.1)