none
重叠I/O 完成例程的问题 RRS feed

  • 问题

  • <dir>
                                      (o o)
                                       (_)
         _______ooO____________________Ooo__________________________________________________________________
        |  _____________                                                                                    
        | |   新连接           |                                                                                   
        | |_____________|              重叠I/O 完成例程                                                     
        |             |                         TCP连接                                                          
        |  ______V______                                                                                    
        | |  socket            |                                                                                   
        | |  bind               |                                                                                   
        | | listen              |                                                                                   
        | |_____________|                                                                                   
        |             |                                                                                          
        |  ______V______________________________                                                            
        | |  WSAAccept(--,--,callback fun, --)                | <--int callback fun(----)调用                            
        | |_____________________________________|    WSARecv, WSASend,....                                  
        |                                                                                              这里要有二个工作线程,哪二个????, 怎样设计?????                ___________________________________________________________________________________________________
                    |_  _| |_  _|
                     |  |     |  |
                    oooO Oooo
    </dir>
    2010年11月11日 1:01

答案

  • 最基本的就是一个监听线程一个通信线程

    Accept的过程是阻塞的

    肯定是用一个专门的线程去处理

    一旦接受到连接就维护到一个列表中

    而当需要通信是就用通信线程在列表中取出通信用到的socket进行通信

    基本就是这个意思

    2010年11月11日 1:37