Reputation: 107
I have read in many places that it is NOT possible to flush the remaining bytes from a receive call on any socket besides a Unix Domain Socket. I need a way to not read all of the incoming data on a TCP socket without closing the connection. server sends 200 bytes I read 20 then go on to send the next request then call receive then the remaining 180 wont be there... How could i go about doing this? Easier to read:
//Server sends 200 bytes
recv(180)
send("request")
//receive whole new response without the remaining bytes from the last one.
Upvotes: 0
Views: 351
Reputation: 73081
The only way to do what you want is to recv()
the 180 unwanted bytes into a buffer, and then ignore (i.e. do not use) the contents of that buffer.
TCP is a strictly FIFO streaming protocol and it doesn't have any explicit provision for dropping bytes from the stream.
Upvotes: 0