View Single Post
Old 03-29-2006, 05:12 AM   #1 (permalink)
jaro
Registered User
 
jaro's Avatar
 
Join Date: Feb 2006
Posts: 9
jaro is on a distinguished road
How do I check if the connection is still alive

Hi there,

I'm wondering is there a function out there that would tell if the socket connection is still alive(or connected).


basically I use some of this to connect to the other "station" ( don't know if these code below would help,but I just want you to know)
Code:
gethostbyname(HOST)
//..............
clientService.sin_addr=*((struct in_addr*)h->h_addr);	 	/* IP address for hostname */
clientService.sin_port = htons("4040");			/* smtp port */
clientService.sin_family = AF_INET;  			/* internet */
//................
ConnectSocket = socket(AF_INET, SOCK_STREAM, 0);
connect( ConnectSocket, (struct sockaddr*) &clientService, sizeof(struct sockaddr) )
//...................
Currently the programs works fine,it is able to retreive and process message from the other "station" (w/c acts a workspaceserver).
The problem is that when I disconnect my pc from the network (by pulling out the network cable), the program still run as if it is still connected to the other "station".

How do I check if the connection is still alive?

Regards,
Jaro
jaro is offline   Reply With Quote