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
voris d.
sponsored links
2
8th July 16:18
alex fraser
External User
Posts: 1
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
alex fraser
3
12th July 07:03
voris d.
External User
Posts: 1
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?
voris d.
4
12th July 07:03
arkady frenkel
External User
Posts: 1
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
arkady frenkel
5
12th July 07:03
arkady frenkel
External User
Posts: 1
gethostbyname returns ERROR_OUTOFMEMORY
"Voris D." <voris@INVALIDgawab.com> wrote in message news:4279ffad_2@x-privat.org...
arkady frenkel
6
12th July 07:03
voris d.
External User
Posts: 1
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.
voris d.
7
12th July 07:03
arkady frenkel
External User
Posts: 1
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
arkady frenkel
8
12th July 07:03
alex fraser
External User
Posts: 1
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.