打印

fdSelect的返回值是0

[复制链接]
1610|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
heweibig|  楼主 | 2016-7-10 15:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
se, ck, TI, SOC, ST
调用ndk_1_94_1\packages\ti\ndk\inc\socket.h中的fdselect函数,函数原型如下:
Int fdSelect( int width, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *timeout );这个fdselect用在判断socket是否准备好的函数里,函数原型如下:
//sock是否准备好
//nRW:0为可读、1为可写
#define SOCKET_ERROR
-1
int commSockIsReady(SOCKET sock, UINT32 nTimeOut, UINT8 nRW)//这里nRW为0
{
int res;
fd_set fds;
int nStatus;
struct sockaddr_in destAddr;
struct timeval timeout;
timeout.tv_sec = nTimeOut/1000;
timeout.tv_usec = (nTimeOut%1000)*1000;
//timeout = {1, 0};
FD_ZERO(&fds);
FD_SET(sock, &fds);
if(nRW == 1)
nStatus = fdSelect(0, NULL, &fds, NULL, &timeout);
else if(nRW == 0)
nStatus = fdSelect(0, &fds, NULL, NULL, &timeout); //
else
assert(FALSE);
if(SOCKET_ERROR == nStatus)
{
res = fdError();
return SOCKET_ERROR;
}
if(0 == nStatus)
{
res = fdError();
return -2;
}
return 0;
}
IGMPTestGroup(BytePtrToUINT32(pIP), 0);     //CCS3.3使用的NDK组播函数
IGMPJoinHostGroup(BytePtrToUINT32(pIP), 0);    //CCS3.1使用的NDK组播函数
遇到的问题是fdSelect的返回值是0,导致commSockIsReady()返回值不正常,无**常接收数据。

相关帖子

沙发
jiahy| | 2016-7-10 15:13 | 只看该作者
还有什么现象?

使用特权

评论回复
板凳
shimx| | 2016-7-10 15:15 | 只看该作者
NDK的原因

使用特权

评论回复
地板
heweibig|  楼主 | 2016-7-10 15:17 | 只看该作者
嗯,如果是NDK的原因,需要如何解决??

使用特权

评论回复
5
zhaoxqi| | 2016-7-10 15:18 | 只看该作者
你是哪个片子了?

使用特权

评论回复
6
heweibig|  楼主 | 2016-7-10 15:21 | 只看该作者
DM642

使用特权

评论回复
7
zhanghqi| | 2016-7-10 15:22 | 只看该作者
帮顶

使用特权

评论回复
8
heweibig|  楼主 | 2016-7-10 15:25 | 只看该作者
好吧,哎

使用特权

评论回复
9
tongbu2015| | 2016-7-12 16:09 | 只看该作者
这个是读写的问题的吧

使用特权

评论回复
10
sunfan101010| | 2016-7-12 17:21 | 只看该作者

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

869

主题

13089

帖子

7

粉丝