说是当ConnectEx函数返回TRUE时,lpdwBytesSent表示发送的字节数,但是msdn上说返回TRUE说明所有的字节都已发送,发了多少字节从dwSendDataLength就可以知道了,因为这时lpdwBytesSent和dwSendDataLength应该是一样的,为什么还需要lpdwBytesSent这个参数呢?

解决方案 »

  1.   

    lpdwBytesSent是实际发送字节数,
    dwSendDataLength是指定发送的字节数,不同概念,
    lpdwBytesSent可能比dwSendDataLength小
      

  2.   

    也就是说lpdwBytesSent可能比dwSendDataLength小,并且函数返回TRUE?msdn上的原话:If the ConnectEx function is successful, a connection was established and all of the data pointed to by the lpSendBuffer parameter was sent to the address specified in the sockaddr structure pointed to by the name parameter.
      

  3.   

    ConnectEx 成功应该指的是连接成功了,连接成功了再返回这次发送的数据的个数On successful return, this parameter points to a DWORD value that indicates the number of bytes that were sent after the connection was established. The bytes sent are from the buffer pointed to by the lpSendBuffer parameter. This parameter is ignored when the lpSendBuffer parameter is NULL.
      

  4.   

    dwSendDataLength 参数表示要发送的字节数。lpdwBytesSent 参数被更新之后用来指明,在建立连接之后如果操作立刻完成的话,成功发送的字节数。