comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: UDP Send gets NETWORK_IS_UNREACHABLE
Date: Tue, 3 Jul 2018 14:16:22 +0200
Date: 2018-07-03T14:16:22+02:00	[thread overview]
Message-ID: <phfpel$j05$1@gioia.aioe.org> (raw)
In-Reply-To: 10ab697c-0f8d-4896-bf4e-44d01f685139@googlegroups.com

On 2018-07-03 12:43, Petter Fryklund wrote:

> We have a need to send a broadcast message. In the test environment on Windows everything is fine. But in the productional environment on Linux we receive Socket Error NETWORK_IS_UNREACHABLE. I have searched the net a bit and it seems like we should use so_bindtodev, but that is not available on GNAT. Does anybody have some advice?

You do not need so_bindtodev, that is for sure.

You could do something like this:

    Create_Socket (Socket, Family_Inet, Socket_Datagram);
    Set_Socket_Option
    (  Socket,
       Socket_Level,
       (Reuse_Address, True)
    );
    Set_Socket_Option
    (  Socket,
       Socket_Level,
       (Broadcast, True)
    );
    Set_Socket_Option
    (  Socket,
       Socket_Level,
       (Receive_Timeout, <some reasonable value if responses expected>)
    );
    Address.Addr := Addresses (Get_Host_By_Name (<my host name>), 1);
    Address.Port := <port>;
    Bind_Socket (Socket, Address);
    Address.Addr := Broadcast_Inet_Addr;
    Address.Port := <port>;
    Send_Socket (Socket, <announce>, Last, Address'Access);
    loop -- Gathering responses
       begin
          Receive_Socket (Socket, <response>, Last, <who is there>);
       exception
         when Socket_Error =>
            null;
       end;
    end loop;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2018-07-03 12:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 10:43 UDP Send gets NETWORK_IS_UNREACHABLE Petter Fryklund
2018-07-03 12:07 ` alby.gamper
2018-07-04  9:53   ` Petter Fryklund
2018-07-03 12:16 ` Dmitry A. Kazakov [this message]
2018-07-04  9:50   ` Petter Fryklund
2018-07-04 10:23     ` Dmitry A. Kazakov
2018-07-04 11:11       ` Petter Fryklund
2018-07-04 13:07         ` Petter Fryklund
2018-07-04 13:42           ` Dmitry A. Kazakov
2018-07-06  5:31             ` Petter Fryklund
2018-07-06  7:23               ` Dmitry A. Kazakov
2018-07-06  8:10                 ` Petter Fryklund
2018-07-08 15:28                   ` Simon Wright
2018-07-06  8:12                 ` Petter Fryklund
2018-07-06  8:28                   ` Dmitry A. Kazakov
2018-07-06  8:48                     ` Petter Fryklund
2018-07-06 18:46                       ` Simon Clubley
2018-07-06  8:24                 ` Petter Fryklund
2018-07-04 13:31         ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox