comp.lang.ada
 help / color / mirror / Atom feed
* Winsock WSAEADDRNOTAVAIL exception raised...
@ 1999-05-04  0:00 Ronald Ali
  1999-05-04  0:00 ` David Botton
  1999-05-10  0:00 ` Ronald Ali
  0 siblings, 2 replies; 3+ messages in thread
From: Ronald Ali @ 1999-05-04  0:00 UTC (permalink / 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;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-05-10  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-04  0:00 Winsock WSAEADDRNOTAVAIL exception raised Ronald Ali
1999-05-04  0:00 ` David Botton
1999-05-10  0:00 ` Ronald Ali

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