I'm developing a peer-to-peer software, that uses .net's SslStream for secure communication.
I use BeginRead() and EndRead() to read the data from the stream asynchronously. (Don't mind the weird callback method too much.. it's from a framework I have to work with right now)
while(Config.State < Config.State.Exit)
{
association.SslStream.BeginRead(
InputBuffer,
InputBufferOffset,
InputBuffer.Length - InputBufferOffset,
iarPort.Post,
null);
yield return Arbiter.Receive(false, iarPort, iar =>
{
try
{
bytesReceived = association.SslStream.EndRead(iar);
}
catch
{
bytesReceived = 0;
}
});
// process data
}
The client will process the received data and start reading again. If the remote client has not sent new data yet, the receiving client will read the old data again. So the data remains in the SslStream after it was read.
Is there a way to tell the client that he has already read this data?