PC Review


Reply
Thread Tools Rate Thread

This code hangs on connect() if connect hangs. how to make this so that if connect hangs i time out after 10 seconds. perhaps there is someway to do this with ioctlsocket and select? can anyone show how to do this?

 
 
Daniel
Guest
Posts: n/a
 
      15th Feb 2005
This code hangs on connect() if connect hangs. how to make this so that if
connect hangs i time out after 10 seconds. perhaps there is someway to do
this with ioctlsocket and select? can anyone show how to do this?

sListerSocks[i].status = 1;
sListerSocks[i].sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock == INVALID_SOCKET)
{
sListerSocks[i].status = 0;
sListerSocks[i].sock = 0;
iCon = -1;
goto _END_ADD_NEW_CONNECTION;
}
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr( pIp );
sListerSocks[i].ip = clientService.sin_addr.s_addr;
clientService.sin_port = htons(8082);
memset(clientService.sin_zero, 0, 8);
if( connect( sListerSocks[i].sock, (SOCKADDR*) &clientService,
sizeof(clientService) ) == SOCKET_ERROR)
{
closesocket(sListerSocks[i].sock);
sListerSocks[i].status = 0;
sListerSocks[i].sock = 0;
iCon = -1;
goto _END_ADD_NEW_CONNECTION;
}


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook hangs and will not let me connect =?Utf-8?B?RGFuYWxtaWdodHk=?= Microsoft Outlook Installation 0 19th Jul 2007 01:08 PM
Re: XP Pro Hangs and Drops DSL Connect When Idle R. McCarty Windows XP General 0 25th Aug 2005 08:39 PM
Address Bar - Hangs 5 minutes + to connect =?Utf-8?B?QW5keSBpbiBXSQ==?= Windows XP Internet Explorer 3 23rd Jun 2005 01:50 AM
attempting to connect to FTP site thru FP hangs... ChrisW Microsoft Frontpage 1 12th Jul 2004 10:00 PM
If SP4 installer hangs, uninstall IIS - it hangs due to IIS trying to connect to "metabase" Skillman Hunter Microsoft Windows 2000 Upgrade 0 4th Sep 2003 08:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 PM.