mog
mog

Reputation: 1343

C# ssl stream wont stop buffering before sending

I am trying to use C# to connect over a ssl socket to a server and send xml data back and forth. It seems that data won't be sent till it has reached a certain packet size 1000 bytes, upon which all the packets are just smashed on top of each other. Is there a way to force ssl library to send out packets as I send them?

I am using SslStream and StreamWriter to send the data, and i have already tried making packet size smaller and setting NoDelay to true to no avail. Is there just something I am missing?

sslStream = new SslStream(sslClient.GetStream(), false, new RemoteCertificateValidationCallback(CertificateValidationCallback));
sslStream.AuthenticateAsClient(appSettings.CBPASServer);
showSslInfo(appSettings.CBPASServer, sslStream, true);
streamWriter = new StreamWriter(sslStream);

...

sslStream.Write(xml);
sslStream.Flush();

Upvotes: 4

Views: 1946

Answers (1)

David
David

Reputation: 34563

My guess is that it's your StreamWriter that is chunking your data. Try setting AutoFlush = true.

Upvotes: 1

Related Questions