...
struct timeval tv;
tv.tv_sec = secs;
tv.tv_usec = uSecs; // Wait up to the specified time to see if data is avail
if( select(-1,&readSet,NULL,NULL,&tv)!= 1)
return UTE_ERROR;
...
程序段,在select这出错了,我查看了一下的定义如下:WINSOCK_API_LINKAGE
int
WSAAPI
select(
IN int nfds,
IN OUT fd_set FAR * readfds,
IN OUT fd_set FAR * writefds,
IN OUT fd_set FAR *exceptfds,
IN const struct timeval FAR * timeout
);故,原select函数第5个参数是const类型的。为什么就不能自动转化,接受这个参数呢?
各位说一下你们的见解!
struct timeval tv;
tv.tv_sec = secs;
tv.tv_usec = uSecs; // Wait up to the specified time to see if data is avail
if( select(-1,&readSet,NULL,NULL,&tv)!= 1)
return UTE_ERROR;
...
程序段,在select这出错了,我查看了一下的定义如下:WINSOCK_API_LINKAGE
int
WSAAPI
select(
IN int nfds,
IN OUT fd_set FAR * readfds,
IN OUT fd_set FAR * writefds,
IN OUT fd_set FAR *exceptfds,
IN const struct timeval FAR * timeout
);故,原select函数第5个参数是const类型的。为什么就不能自动转化,接受这个参数呢?
各位说一下你们的见解!
int select_ret = 0;
timeval tvvalue = {0, 50000}; //注意这里
fd_set fdread;
while(TRUE)
{
FD_ZERO(&fdread);
FD_SET(m_socket,&fdread);
select_ret = select(0,&fdread,NULL,NULL,&tvvalue);
if (SOCKET_ERROR == select_ret)
{
Trace("SOCKET_ERROR == select_ret\n");
return -1;
}
if (select_ret > 0)
{
if (FD_ISSET(m_socket,&fdread))
{
ret_len = recv(m_socket,buf,len,0);
return ret_len;
}
}
}
struct timeval tv;
tv.tv_sec = secs; //注意这里
tv.tv_usec = uSecs; //注意这里 // Wait up to the specified time to see if data is avail
if( select(-1,&readSet,NULL,NULL,&tv)!= 1)
return UTE_ERROR;
...
if( select(-1,&readSet,NULL,NULL,(const timeval *)&tv)!= 1)