troubleshooting Question

Check if a socket in Windows is connected or not

Avatar of ProjectZIG
ProjectZIG asked on
CInternet ProtocolsWindows Networking
5 Comments1 Solution375 ViewsLast Modified:
Hey guys,

  I have a DLL that opens a socket connection, and handles everything.  I have another DLL set up, called from the same program, that I would like to pass the socket to and have it check to see if the socket is still connected or not.

  Something like this:
 
  SOCKET sock;
  ..do other work, such as connect, etc...
  int ret = isSocketConnected(sock);

  And have the return code be a negative number if the socket isn't connected anymore, and anything other than a negative number if the socket IS connected and there are no existing errors.  If possible, I want to do this without recv() as I want to leave the data in the pipe, so my program can handle it.  This will simply be to check and see if the socket is still connected, so I can re-connect if needed.

  Is this possible?

-Kevin
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros