...
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类型的。为什么就不能自动转化,接受这个参数呢?
各位说一下你们的见解! 

解决方案 »

  1.   

    int   ret_len   =   0;   
      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;   
      }   
      }   
      }   
      

  2.   

    定义的tv已经附值了。如下:... 
    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; 
    ... 
      

  3.   

    把struct timeval tv;前面的struct去掉。
      

  4.   

    或者 强制转换下
    if( select(-1,&readSet,NULL,NULL,(const timeval *)&tv)!= 1) 
      

  5.   

    把struct timeval tv;前面的struct去掉。还是报同样的错。奇怪了。
      

  6.   

    把struct timeval tv;前面的代码帖出来看看。另外struct timeval tv与select是在同一函数中吗?有没有使用名空间?