微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > TI工程师,CC3200 tcp_socket问题。。

TI工程师,CC3200 tcp_socket问题。。

时间:10-02 整理:3721RD 点击:

TCP 当服务器时,需要外部连接,TCP连接成功了

但是这是PC tcp上位机不发送数据时,程序死等在sl_Recv函数。

// waits for 1000 packets from the connected TCP client
while (lLoopCount < g_ulPacketCount)
{
iStatus = sl_Recv(iNewSockID, g_cBsdBuf, iTestBufLen, 0);

// iStatus = sl_Send(iNewSockID, g_cBsdBuf, iTestBufLen, 0);
if( iStatus <= 0 )
{
// error
ASSERT_ON_ERROR( sl_Close(iNewSockID));
ASSERT_ON_ERROR(sl_Close(iSockID));
ASSERT_ON_ERROR(TCP_SERVER_FAILED);
}

lLoopCount++;
}

我添加超时接受,修改相应的参数,也是一样的效果

SlTimeval_t sltimeval;

sltimeval.tv_sec = 0;
sltimeval.tv_usec = 300;

// setting socket option to make the socket as non blocking
iStatus = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_RCVTIMEO ,
&sltimeval, sizeof(sltimeval));

请问TI工程师,怎么修改相应的代码才能够不死等接受数据,不然这样只能加操作系统?

Louis,

您好!

您如果添加了超时接收,那应该是不会出现您说的死等接收的情况发生。根据以往的经验,您更新一下service pack再试一下,谢谢!

谢谢您回复!

service pack应该是最新的。

下面是信息:

[WLAN EVENT] STA Connected to the AP: EmbedSky_test , BSSID: 0:27:19:64:f8:a8
Host Driver Version: 1.0.0.1
Build Version 2.0.7.12.31.0.0.4.5.1.5.3.20
[WLAN EVENT]Device disconnected from the AP: EmbedSky_test,BSSID: 0:27:19:64:f8:a8 on application's request
Device is configured in default state
Device started as STATION
Connecting to AP: EmbedSky_test ...
[WLAN EVENT] STA Connected to the AP: EmbedSky_test , BSSID: 0:27:19:64:f8:a8
[NETAPP EVENT] IP Acquired: IP=192.168.1.247 , Gateway=192.168.1.2
Connected to AP: EmbedSky_test
Device IP: 192.168.1.247

请问有办法解决吗?应该是有的,我还没有找到相关的参数设置?可以提供吗?

通过下面设置参数,没有效果,API我大部分看过了,找不到。

sltimeval.tv_sec = 0;
sltimeval.tv_usec = 300;

// setting socket option to make the socket as non blocking
iStatus = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_RCVTIMEO ,
&sltimeval, sizeof(sltimeval));

你在创建SOCKET之后,加下面这个调用去设置它的类型为non-blocking:

g_NonBlocking = 1;
g_Status = sl_SetSockOpt(g_Socket, SL_SOL_SOCKET, \
SL_SO_NONBLOCKING, &g_NonBlocking, \
sizeof(g_NonBlocking));

已经解决了,确实要这样,被TCP SOCKET例子给忽悠 了,一定要在创建之后,马上设置参数,不能再连接成功修改。

 

谢谢您!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top