Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if Server Socket is Active?? 1

Status
Not open for further replies.

Wings

Programmer
Feb 14, 2002
247
US
Hi,
I have created a server/client socket based chat program.
The only problem is that I have no idea how to go about checking whether or not the server is active before Attempting to activate the client socket, and recieving a socket error due to an inactive server. Any method of checking or error handling this problem would be appreciated.

Thanks
 
goto:
this will tell you one method of detecting socket errors. There are a few arguments that will tell you if a server is active or not, they are all inside the OnError event.

this is the error code I use to determine if the server is running or not.

switch (ErrorCode)
{
case 10061:
/* Connection refused */
Label1->Caption = "Server currently down (10061)";
break;
}

look in the
"Help->MS SDK Help Files->Windows Sockets 2 Reference" and look for their error codes. They have a complete list. I typically use all of the possible errors, but the one given will tell you if the server is down or not. Cyprus
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top