日期:2014-05-20 浏览次数:21253 次
public override int Send(byte[] buffer) { if (Connected) { lock (clientSocket) { return clientSocket.Send(buffer); } } else return COMM_FAILURE; }
/* If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode. On nonblocking stream oriented sockets, the number of bytes written can be between 1 and the requested length, depending on buffer availability on both the client and server computers. The select, WSAAsyncSelect or WSAEventSelect functions can be used to determine when it is possible to send more data. */
/* blocking send() and delayed ack Ralph_G | Edit | Hide History Please Wait Please Wait blocking send() and delayed ack | Modified on 12/10/2008 1:39 AM by Ralph_G I have an (time critical) application where a sender sends large blocks of data in constant time intervals using a blocking call to send(). The receiver doesn't return anything. Sometimes nothing is sent for about 200ms (which means that we have to drop packets an the sender side), I used wireshark to log the network traffic and saw that always when the 200ms pause occured the TCP ACK from the sender was delayed. I assume that we sometimes send an even number of packets, causing the ACK to be sent immediatly and sometimes an uneven number of packets, causing the TCP delayed ACK mechanism to delay the ACK for 200 ms. And i assume that the blocked send() returns only after it received an ACK for the last sent packet - is this true? If I set the TcpAckFrequency registry key to 1 on the receiver side, the problem disappears. TCP_NODELAY is set on both sides. I'm looking for a better solution than setting the registry key, should it be possible to resolve the issue using overlapped I/O? */