Sign in to follow this  
goohead

winsock error 10054 WSAECONNRESET when using loopback ip - why?

Recommended Posts

goohead    122
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
nifty    122
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
XXX_Andrew_XXX    340
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

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