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 ==
我在论坛里面没有找到相关的解释
谢谢!
wenrui zhai:
回复 jie huang4:
mcsdk的client例程,用DaemonNew创建端口1000的dtask_tcp_datasrv进程,用recv.exe测试没有问题,但是自己用Task_create创建任务,然后创建socket连接不上,端口也使用的是1000,
没有明白您说的服务器端没有开?
user6027759:
回复 wenrui zhai:
您好,请问您的问题解决没有,我也遇到跟您一样的问题。