Winsock2.0 VC++2010 issue

With this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
WSADATA wsaData;
	int wsint;

	wsint = WSAStartup(MAKEWORD(2,0), &wsaData);

	if(wsint != 0)
	{
		WSACleanup();
		return nullptr;
	}
	
	struct sockaddr_in Address;
	struct hostent* pHent;
	
	if(Address.sin_addr.s_addr == INADDR_NONE)
		pHent = gethostbyname(servername);
	
	if(pHent == NULL)
		return nullptr;


The assignment operator= is highlighted by intellisense with the error message:
Error: a value of type "hostent *" cannot be assigned to an entity of type "hostent *"
This makes no sense as gethostbyname() returns a hostent*.
The other problem is that getaddrinfo() is undefined even with the <WinSock2.h> included.
I have the ws2_32.lib in the linker - so what can be going wrong??
There's nothing wrong with the syntax of what you've posted (except servername not being defined).

getaddrinfo() is declared in ws2tcpip.h. All you have to do is hit F1 and read the help.
Thanks your reply was helpful and the getaddrinfo() issue is resolved.
Still not sure about the squiggles under the =assignment operators telling me I can't assign a hostent* to hostent*. Each time I hit F1 I get different operator= overloading code from msdn.
Perhaps struct hostent is corrupted on my system?
Finally got rid of the squiggles by doing this:
pHent = (hostent*)gethostbyname(servername);
a conversion cast - really? On the same type...c'mon Bill (VC++2010, the original code compiles just fine on GCC and VC2008)
Topic archived. No new replies allowed.