Sign in to follow this  

VC++ Socket Connection Error 10054

This topic is 3861 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 having problems w/ my client/server. I wrote both ends and I keep getting Error 10054 (Socket Forcilbly Closed By Server). However, I don't force a close. On both sides, I checked to make sure my thread wasn't dying and it seems operational. What could cause this? On the Server Side: int result = send(ClientSocket, Buffer, BlockSize, 0); if(result == SOCKET_ERROR) { int SocketError = WSAGetLastError(); //Error 10054 returns here??!! TRACE(_T("Error Code(%d)\n"), SocketError); } else { TRACE(_T("Send(%d)\n"), result); Sleep(1); } Client Side: if(select(1, &fdset, NULL, NULL, &ConnTimeOut) > 0) { ULONG DataAvail = 0; ioctlsocket(ServerSocket, FIONREAD, &DataAvail); if(DataAvail >= BlockSize) { if(recv(ServerSocket,Buffer,BlockSize, 0) == BlockSize) { //DO STUFF LATER ON DATA IN BUFFER } } } Both exist in a thread and both thread seem to run fine. Thanks in advance for any help.

Share this post


Link to post
Share on other sites
I can work around it by closing the socket and re-connecting. However, my server is streaming data over to my client. It would have to constantly close and re-open the connection whenever the problem happened. It would not be a big deal if my server were only sending a message over once in a while. Should I take a different approach to streaming data from my server?

Share this post


Link to post
Share on other sites
I think you're giving too little information for anyone to guess what's going on.
Are you using TCP or UDP?
What version of what OS on client and server?
Are they running on the same machine or not?
What does the network inbetween look like?
Any firewalls installed?

Share this post


Link to post
Share on other sites
You're right.

Are you using TCP or UDP?
TCP

What version of what OS on client and server?
Both WinXP

Are they running on the same machine or not?
Two Different Laptops

What does the network inbetween look like?
Both Connected to Linksys Router

Any firewalls installed?
Just the free one you get w/ WinXP. Connects OK. Just cuts off after a little while.

Share this post


Link to post
Share on other sites
Are you sending a blocksize of 0?

Oh wait, doesn't it have to do with some weird Windows network privileges? Try with the firewalls off. Also make sure each machine can see each other in the network neighbourhood, something like that. I'm not a windows expert, someone should be able to formulate what I'm trying to say more clearly :)

It's also possible the firewall is reporting it as an attack and closes te connection. Check out the logs and see if the connection attempt is detected, and closed by the firewall. Could be a port problem.

Share this post


Link to post
Share on other sites
Try using peer-to-peer (ad hoc) network mode, and see if it still happens. Or use a cross-over cable straight between them. I've seen a number of "wireless routers" that behave quite strangely, including re-setting themselves every so often, and then taking all connections with them.

Share this post


Link to post
Share on other sites

This topic is 3861 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.

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