From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, WEIRD_QUOTING autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc8d0,e3e726b9ad52ca23 X-Google-Attributes: gidfc8d0,public X-Google-Thread: 103376,e3e726b9ad52ca23 X-Google-Attributes: gid103376,public From: David Botton Subject: Re: Winsock WSAEADDRNOTAVAIL exception raised... Date: 1999/05/04 Message-ID: <372F7F92.BF014DB6@Botton.com>#1/1 X-Deja-AN: 474104568 Content-Transfer-Encoding: 7bit References: <372f2583.102091187@news.exit109.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@gate.net X-Trace: news.gate.net 925859736 91458 199.227.35.62 (4 May 1999 23:15:36 GMT) Organization: CyberGate, Inc. Mime-Version: 1.0 NNTP-Posting-Date: 4 May 1999 23:15:36 GMT Newsgroups: alt.winsock.programming,comp.lang.ada Date: 1999-05-04T23:15:36+00:00 List-Id: 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;