SSL data read and write transfer rate managing efficiently in Server
Asked Answered
R

1

6

How to control data write and read efficiently? OR What are the possible reason for decreasing read/write speed? Is there any mistake in my code? Currently it is very slow.

I am using below code:

listener.BeginAcceptTcpClient(new AsyncCallback(AcceptCallback), listener);
 .....
// Inside AcceptCallback()
dataStream = client.GetStream();
sslStream = new SslStream(dataStream, true, new RemoteCertificateValidationCallback(ValidateCert));

sslStream.AuthenticateAsServer(serverCertificate);
....
sslState.sslStream.BeginRead(buffer, 0, Length, StartSSLSession, sslState);


// Inside StartSSLSession(IAsyncResult ar)
sslStream.Write(responseBuffer);
sslStream.Flush();

Please give suggestions or solutions..

Here I attached the image of current length of the data transferring from client to server. Is this possible to increase the length of the client data..? enter image description here

Regan answered 2/2, 2017 at 12:15 Comment(0)
I
0

Add a buffer between dataStream and sslStream

dataStream = client.GetStream();
bufferedStream = new BufferedStream(dataStream);
sslStream = new SslStream(bufferedStream, true, new RemoteCertificateValidationCallback(ValidateCert));

This will cause output of SslStream to buffer (default buffer size is 4096 bytes) output to the socket's data stream, and therefore send bigger chunks of data much more efficiently.

Interpleader answered 9/2, 2017 at 19:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.