C# Class IronSmarkets.Sockets.SafeSslStream

The purpose of this class is to wrap SslStream and provide thread-safe Read and Write blocking operations. The reason this is necessary is because NetworkStream is thread-safe for simultaneous reads and writes as long as there is a single reader and a single writer. SslStream, on the other hand, does not guarantee this safety. However, we can use BeginRead/BeginWrite to do asynchronous operations and simply signal to the main thread that they've completed. Performance will suffer slightly, but TLS network performance incurs its own buffering penalties by nature.
Inheritance: Stream
Show file Open project: smarkets/IronSmarkets

Public Methods

Method Description
Flush ( ) : void
Read ( byte buffer, int offset, int count ) : int
SafeSslStream ( SslStream stream ) : System
Seek ( long offset, SeekOrigin origin ) : long
SetLength ( long length ) : void
Write ( byte buffer, int offset, int count ) : void

Private Methods

Method Description
ReadCallback ( IAsyncResult ar ) : void
WriteCallback ( IAsyncResult ar ) : void

Method Details

Flush() public method

public Flush ( ) : void
return void

Read() public method

public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
return int

SafeSslStream() public method

public SafeSslStream ( SslStream stream ) : System
stream System.Net.Security.SslStream
return System

Seek() public method

public Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
return long

SetLength() public method

public SetLength ( long length ) : void
length long
return void

Write() public method

public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
return void