0

How to know size of packet sent in SslStream Asynchronous Socket, since EndWrite doesn't have output?

    public void DataSent(IAsyncResult result)
    {
        SslStream stream = null;
        try
        {
            if (result != null)
            {
                stream = result.AsyncState as SslStream;                
                if (stream != null && stream.CanWrite)
                {
                    stream.EndWrite(result);                        
                    this.m_sendSignal.Set();

                    // how to calculate size of packet received in here ???
                }
            }
        }
        catch (Exception ex)
        {
             MessageBox.Show(ex.message);                
        }
    }
new bie
  • 2,745
  • 6
  • 24
  • 26
  • The amount of data sent is the amount you specify in the BeginWrite call. SSL (like TCP) does not preserve message boundaries (i.e., it transports a stream of bytes, not a sequence of messages). The data gets fragmented into SSL records which get fragmented into IP packets. But this is fully transparent to the application. There is no way for the application to determine the sizes of IP packets sent, because the application does not need (and should not rely on) this information. What are you trying to achieve? – dtb Mar 04 '13 at 01:12
  • You are right, thanks for details explanation. I can read size of sent packet if used *asynchronous socket* but not for *ssl stream asynchronous socket*. – new bie Mar 04 '13 at 08:10

0 Answers0