Sign in to follow this  

winsock error 10054 WSAECONNRESET when using loopback ip - why?

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 ( 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

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("") ;
pInAddr = (struct in_addr *)*pConnectedHost->h_addr_list ;
lpszIPAddr = inet_ntoa(*pInAddr) ;
m_ServerInfo.sin_addr.S_un.S_addr = inet_addr(lpszIPAddr) ;


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this