comp.lang.ada
 help / color / mirror / Atom feed
From: RonAli@WriteMe.com (Ronald Ali)
Subject: Winsock WSAEADDRNOTAVAIL exception raised...
Date: 1999/05/04
Date: 1999-05-04T16:59:07+00:00	[thread overview]
Message-ID: <372f2583.102091187@news.exit109.com> (raw)

I'm getting the WSAEADDRNOTAVAIL (#10049) error on the Bind (...)
command.  I'm on NT 4.0 (SP3), using Gnat Ada compiler & win32-winsock
functions.

Could someone out there in the know suggest a fix ?
Could DHCP running on our network be a cause of the error?

Snippets of the source code follow.  I will send the full Package spec
& body and Test procedure upon request.

--=====================================================
with WinSock;     use WinSock;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_WinSock is
begin
   Put_Line ("Test_Winsock...");
   Startup_Sockets; -- WSASTARTUP works fine

   Put_Line ("The name    of this host is " & Get_Host_Name);
   Put_Line ("The address of this host is " & Get_Host_Address);

   Local := (Sin_Family => AF_INET,
             Sin_Port   => htons (5001),
             Sin_Addr   => To_U_32 (Host_Address.h_addr_list'Address),
             Sin_zero   => (others => '*')
            );

   Open_Listen_Socket;   -- WSASTARTUP works fine
   Set_Socket_Option;     -- WSASTARTUP works fine
   Bind_Listen_Socket;    -- raised WSAEADDRNOTAVAIL
    . . . 
end Test_WinSock;
--=====================================================

package body WinSock is
   . . .

--------------------------------------------------------------------
   procedure Open_Listen_Socket is
      Protocol_Used : Integer := IPPROTO_IP;
   begin
      Listen_Socket := socket_func (Addr_Family => AF_INET,
                                    Socket_Type => SOCK_STREAM,
                                    Protocol    => Protocol_Used);

      If Listen_Socket = INVALID_SOCKET then
         Put ("INVALID ""Listen_Socket""");
--         raise UNKNOWN_SOCKETS_ERROR;
      end if;
   end Open_Listen_Socket;


--------------------------------------------------------------------
   procedure Set_Socket_Option is
      Result : Integer;
      Optval : Char_Array := "SO_REUSEADDR";
   begin
      Result := setsockopt (The_Socket => Listen_Socket,
                            level      => SOL_SOCKET,
                            optname    => SO_REUSEADDR,
                            optval     => Optval,
                            optlen     => Optval'Size);
      Check_Result (WSAGetLastError);
   end Set_Socket_Option;


--------------------------------------------------------------------
   procedure Bind_Listen_Socket is
      Result : Integer;
   begin
      Result := Bind (The_Socket  => Listen_Socket,
                      The_Address => To_Sock_Addr (Local'Address),
                      Name_Length => Local'Size / 8);
      Check_Result (WSAGetLastError);
   end Bind_Listen_Socket;
   . . .
end WinSock;




             reply	other threads:[~1999-05-04  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-04  0:00 Ronald Ali [this message]
1999-05-04  0:00 ` Winsock WSAEADDRNOTAVAIL exception raised David Botton
1999-05-10  0:00 ` Ronald Ali
replies disabled

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