我是用CC3100座位STA模式连上路由器,然后创建server等待cilent建立连接,CC3100在有cilent连上就往这个socket发送5个字节的数据,但总是发送失败,想请教下什么情况下会发送失败?
代码是在freertos上跑,发送代码如下:
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.
我是用CC3100座位STA模式连上路由器,然后创建server等待cilent建立连接,CC3100在有cilent连上就往这个socket发送5个字节的数据,但总是发送失败,想请教下什么情况下会发送失败?
代码是在freertos上跑,发送代码如下:
可以在仿真状态下查看一下,getsocketID是否正确的获取了正确的ID,
sTestBufLen = BUF_SIZE;
//filling the TCP server socket address
sAddr.sin_family = SL_AF_INET;
sAddr.sin_port = sl_Htons((unsigned short)usPort); //目的IP地址端口号
sAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp); //目的IP地址IP_ADDR-手机上连接USR软件后配置TCP Server设置端口号并查看本机IP地址
iAddrSize = sizeof(SlSockAddrIn_t);
// creating a TCP socket
iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
if( iSockID < 0 )
{
ASSERT_ON_ERROR(SOCKET_CREATE_ERROR);
}
// connecting to TCP server
iStatus = sl_Connect(iSockID, ( SlSockAddr_t *)&sAddr, iAddrSize); //<连接>目的IP地址及端口号
if( iStatus < 0 )
{
// error
sl_Close(iSockID);
ASSERT_ON_ERROR(CONNECT_ERROR);
}
// sending multiple packets to the TCP server
// sending packet
iStatus = sl_Send(iSockID, g_cBsdBuf, sTestBufLen, 0 );