• Advertisement
Sign in to follow this  

winsock error 10054 WSAECONNRESET when using loopback ip - why?

This topic is 4847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a client/server based network game. It uses UDP. Each instance of the game as two sockaddr_in varaibles, one for itself (m_LocalInfo) and one for the server (m_ServerInfo). It was my intention to treat a single player game as no differently than any other client who wasn't playing on the actual server machine. I was going to set the m_ServerInfo to point to the loopback IP address (127.0.0.1) and just receive messages in the same receive queue that all the messages normally come in on. My problem is that even though I can send messages fine to the loopback IP address, when I try to receive those messages I get a winsock error 10054 on them. If I set the m_ServerInfo to the machines actual IP address, I can send and receive messages just fine. Has anyone else tried this kind of setup? I wanted to avoid writing any more client/server specific code than necessary and sending messages back to itself using the loopback IP seemed like a good way to avoid unneeded network traffic. Any thoughts on this would be appreciated. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Hi,

when specifying the address part of sockaddr_in, have you tried using:

TCHAR *lpszIPAddr = 0 ;
hostent *pConnectedHost = 0 ;
struct in_addr *pInAddr = 0 ;

// Please check for NULL return
pConnectedHost = gethostbyname("127.0.0.1") ;
pInAddr = (struct in_addr *)*pConnectedHost->h_addr_list ;
lpszIPAddr = inet_ntoa(*pInAddr) ;
m_ServerInfo.sin_addr.S_un.S_addr = inet_addr(lpszIPAddr) ;

regards

Share this post


Link to post
Share on other sites
Just an idea...

Under win2k without SP2 this can occur for UDP sockets, it is documented at http://support.microsoft.com/kb/263823 . Not so long ago this was discussed on these forums, you might find more help there.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement