This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
s = socket(AF_INET, SOCK_STREAMNC, IPPROTO_TCP);
if( s == INVALID_SOCKET )
{
printf("failed socket create (%d)\n",fdError()); goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_len = sizeof( sin1 );
sin1.sin_addr.s_addr = IPAddr;
sin1.sin_port = htons(1001);
// Configure our timeout to be 5 seconds
timeout.tv_sec = 5; timeout.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
// Connect socket
if ( connect( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
printf("failed connect (%d)\n",fdError());
goto leave; }
您好!
新建一个tcp socket connect( s, (PSA) &sin1, sizeof(sin1) )不上,显示错误信息
== Start TCP Send Test ==
00006.000 TCP: Retransmit Timeout
00030.000 TCP: Retransmit Timeout
00075.000 TCP: Keep Timeout
failed connect (60)
== End TCP Send Test ==
我在论坛里面没有找到相关的解释
谢谢!
fdOpenSession((HANDLE)TaskSelf() );
SOCKET s;
struct sockaddr_in sin1,sin2;
UINT32 test,j;
char *pBuf = 0;
struct timeval timeout;
UINT32 startS, startMS;
UINT32 endS, endMS;
printf("\n== Start TCP Send Test ==\n");
// Create test socket
s = socket(AF_INET, SOCK_STREAMNC, IPPROTO_TCP);
if( s == INVALID_SOCKET )
{
printf("failed socket create (%d)\n",fdError());
goto leave;
}
// Prepare address for connect
bzero( &sin1, sizeof(struct sockaddr_in) );
sin1.sin_family = AF_INET;
sin1.sin_len = sizeof( sin1 );
sin1.sin_addr.s_addr = inet_addr(LocalIPAddr);
sin1.sin_port = htons(1000);
// Connect socket
if ( bind( s, (PSA) &sin1, sizeof(sin1) ) < 0 )
{
printf("failed bind (%d)\n",fdError());
goto leave;
}
// Configure our timeout to be 5 seconds
timeout.tv_sec = 5;
timeout.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof( timeout ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof( timeout ) );
// Prepare address for connect
bzero( &sin2, sizeof(struct sockaddr_in) );
sin2.sin_family = AF_INET;
sin2.sin_len = sizeof( sin2 );
sin2.sin_addr.s_addr = inet_addr(dstIPAddr);
sin2.sin_port = htons(1000);
// Connect socket
if ( connect( s, (PSA) &sin2, sizeof(sin2) ) < 0 )
{
printf("failed connect (%d)\n",fdError());
goto leave;
}
改写过后出现failed connect(61)