SSL data transfer and read speed is efficiently managed by the server

How to effectively manage writing and reading data? OR What is the possible reason for the decrease in read / write speed? Is there an error in my code? He is currently very slow.

I am using the code below:

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 provide suggestions or solutions.

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

+5
source share
1 answer

Add buffer between dataStream and sslStream

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

This will lead to the output of SslStream (the default buffer size is 4096 bytes) to the socket data stream and, therefore, more efficient sending of large pieces of data.

0
source

Source: https://habr.com/ru/post/1263731/


All Articles