JustFillingIn
Programmer
I am calling a web service using a socket call. I want to prevent my client app from 'hanging' until the socket call times out if the service is not running. The app is working fine if the service is running.
//Create the Socket
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
printf("errno %d: %s\n",errno,strerror(errno));
set_output_data(in_out_address->error,
"E991",
ERROR_SIZE);
return;
};
printf("errno %d: %s\n",errno,strerror(errno));
printf("sockfd %d: %s\n",sockfd,"socket call");
//Connect
errno=0;
connresult = connect(sockfd,(struct sockaddr *)&server_addr,
sizeof(server_addr));
if (connresult < 0)
{
printf("errno %d: %s\n",errno,strerror(errno));
set_output_data(in_out_address->error,
"E992",
ERROR_SIZE);
return;
}
printf("errno %d: %s\n",errno,strerror(errno));
printf("connresult %d: %s\n",connresult,"connection call");
// check if service is running before we send data
//Create the Socket
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
printf("errno %d: %s\n",errno,strerror(errno));
set_output_data(in_out_address->error,
"E991",
ERROR_SIZE);
return;
};
printf("errno %d: %s\n",errno,strerror(errno));
printf("sockfd %d: %s\n",sockfd,"socket call");
//Connect
errno=0;
connresult = connect(sockfd,(struct sockaddr *)&server_addr,
sizeof(server_addr));
if (connresult < 0)
{
printf("errno %d: %s\n",errno,strerror(errno));
set_output_data(in_out_address->error,
"E992",
ERROR_SIZE);
return;
}
printf("errno %d: %s\n",errno,strerror(errno));
printf("connresult %d: %s\n",connresult,"connection call");
// check if service is running before we send data