Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > WINDOWS PROGRAMMING (NNTP) > gethostbyname returns ERROR_OUTOFMEMORY
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 8th July 16:18
voris d.
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY



Whenever I try to call gethostbyname(NULL) WSAGetLastError returns
ERROR_OUTOFMEMORY.

However, this is the first call in my code (after WSAStartup of course) so I
think it should be some bug in winsock dll.

Any help is much appreciated.

Thanks
  Reply With Quote


  sponsored links


2 8th July 16:18
alex fraser
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY



What does gethostbyname(NULL) return? Unless it returns NULL,
WSAGetLastError() is not meaningful.

What is the behaviour you expect from the call? In other words, what are you
trying to do?

Alex
  Reply With Quote
3 12th July 07:03
voris d.
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


I'm calling gethostbyname(NULL) to get the ip address of each network
adapter.
The return value is correct, altough the debugger continues to report the
ERROR_OUTOFMEMORY error at each call to gethostbyname, which is the same
error reported by GetLastError().
I don't know why this error arises, maybe some memory leak in the winsock
library?
  Reply With Quote
4 12th July 07:03
arkady frenkel
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


Function demand the name as null terminated string but not null.
If you need current host use
gethostname and result name give to gethostbyname
Arkady
  Reply With Quote
5 12th July 07:03
arkady frenkel
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


"Voris D." <voris@INVALIDgawab.com> wrote in message news:4279ffad_2@x-privat.org...
  Reply With Quote
6 12th July 07:03
voris d.
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


But MSDN says:
If null is provided in the name parameter, the returned string is the same
as the string returned by a successful gethostname function call.
  Reply With Quote
7 12th July 07:03
arkady frenkel
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


Sorry, you are right , I just never used it with null , did you receive null
as a
return param ( hostent *) ? Only that tell that error happen.
And I don't think that that happen because you successfully read IP from
hostent
Arkady
  Reply With Quote
8 12th July 07:03
alex fraser
External User
 
Posts: 1
Default gethostbyname returns ERROR_OUTOFMEMORY


MSDN also says:

"If no error occurs, gethostbyname returns a pointer to the hostent
structure described above. Otherwise, it returns a null pointer and a
specific error number can be retrieved by calling WSAGetLastError."

Which means, as I said before, WSAGetLastError() is meaningless unless
gethostbyname() returns NULL.

Alex
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666