>>> Calvin wrote:
C> As I need to receive several packets in one connection, I wrote the
C> following code.
C> for ( ; ; )
C> recv(sockFD, buf, MAX_BUF-1, 0);
C> My problem is, if the sender only sends a packet with data "abc", the
C> receiver receives the data "abc" indefinitely. It seems to me that
C> recv doesn't really clear the socket buffer that it keep retrieving
C> the same data as if they are new.
This is impossible.
C> Do I miss something? Your help is highly appreciated. Thanx.
You don't check recv() return code. If it received nothing until returned,
buffer isn't overwritten.