用select异步,怎么实现connect的非阻塞?
能否给出实现代码?

解决方案 »

  1.   

    创建非阻塞的套接字,使用select,然后判断select返回的事件。
    具体代码见《Windows 网络编程》
      

  2.   

    #include <winsock.h>
    http://yingfeng7926yueyue.spaces.live.com/blog/cns!CEADD079FE6BD9D9!144.entry原型int select(
    int nfds,
    fd_set* readfds,
    fd_set* writefds,
    fd_set* exceptfds,
    const struct timeval* timeout
    );nfds:本参数忽略,仅起到兼容作用。
       readfds:(可选)指针,指向一组等待可读性检查的套接口。
       writefds:(可选)指针,指向一组等待可写性检查的套接口。
       exceptfds:(可选)指针,指向一组等待错误检查的套接口。
       timeout:select()最多等待时间,对阻塞操作则为NULL。
      

  3.   

    参考这个!
    http://blog.csdn.net/jasonM2008/archive/2009/03/10/3976844.aspx