connect() succeeds after n-attempts.... why?
Hello,
Ive a problem. I wrote a sample TCP client which tries to connects to some
server (IPAddress:Port) in a loop. The connect() call succeeds after few
attempts.
We tried the same code on HP-UX and Solaris, where it was working properly
(caonnect() failing all the time...)
Please support
Regards
Wilson
.........
while( 1 )
{
int fd = socket( AF_INET, SOCK_STREAM, 0 );
if( fd < 0 )
{
cout << "socket() failed" << endl;
return fd;
}
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr( "134.15.15.39" );
addr.sin_port = 10000;
if( connectStatus = connect( fd, ( const sockaddr *)&addr,
sizeof( addr ) ) < 0 )
{
cout << "connect() failed" << endl;
close( fd );
// return -1;
}
if( connectStatus == 0 )
if( connectStatus == 0 )
{
cout << "connect succedded " << endl;
break;
}
}
cout << "out of while loop " << endl;
........
[But the connect call succeeds after a few repetitions.]
--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: