就是说一般处理新连接的时候,是处理新连接,此时客户端没有发送任何数据,接受到连接后,Post一个Recv还是等等一个新连接,同时也等待客户端连接后有数据发送在处理呢?其实就是在 m_pAcceptEx( pSrvNode->m_hSocket,sAcp,(void*)pIOMem->m_szBuf,0,//这里用0,还是不用0 
    sizeof(sockaddr_in)+16,
                        sizeof(sockaddr_in)+16,&dwRecv,&pIOMem->m_olp );这2种方式一般有啥优缺点?

解决方案 »

  1.   

    BOOL AcceptEx(
      __in   SOCKET sListenSocket,
      __in   SOCKET sAcceptSocket,
      __in   PVOID lpOutputBuffer,
      __in   DWORD dwReceiveDataLength,
      __in   DWORD dwLocalAddressLength,
      __in   DWORD dwRemoteAddressLength,
      __out  LPDWORD lpdwBytesReceived,
      __in   LPOVERLAPPED lpOverlapped
    );lpOutputBuffer 
    A pointer to a buffer that receives the first block of data sent on a new connection, the local address of the server, and the remote address of the client. The receive data is written to the first part of the buffer starting at offset zero, while the addresses are written to the latter part of the buffer. This parameter must be specified.----------
    可以服务器可以在接收连接的收到客户端发送的第一块数据,这样就可以根据接收的数据,然后判断是否继续提供服务或者T掉,而不用等待客户端send 单独的数据。这样提高的效率。
      

  2.   

    同意楼上,IOCP是允许在连接的同时 发送一个数据过去的