comp.lang.ada
 help / color / mirror / Atom feed
From: David Botton <David@Botton.com>
Subject: Re: Winsock WSAEADDRNOTAVAIL exception raised...
Date: 1999/05/04
Date: 1999-05-04T23:15:36+00:00	[thread overview]
Message-ID: <372F7F92.BF014DB6@Botton.com> (raw)
In-Reply-To: 372f2583.102091187@news.exit109.com

WSAEADDRNOTAVAIL 

(10049) 

Cannot assign requested address. 

The requested address is not valid in its context. Normally results from
an attempt to bind to an address that is not valid for the local
machine, or connect/sendto an address or port that is not valid for a
remote machine (e.g. port 0). 


Ronald Ali wrote:
> 
> 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 Winsock WSAEADDRNOTAVAIL exception raised Ronald Ali
1999-05-04  0:00 ` David Botton [this message]
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