News  [SoftwareSite

Latest News
Older News
RSS Feed
Complete Projects
Useful Classes
Top Downloads
Message Board
Send Comments
Software License Buttons
Forums -> Security Library Forum
SecureSocket.Send blocks  
by Juan Pedro Martinez [jpmartinez at hubcc dot ca]
posted on 2003/09/24


I have the code below. The ssl handshake, certificate validation works fine. After the loop has been executed
a few times (several hundred bytes transfered) the program blocks on Send and never comes back. I have a try/catch blcok for exceptions but not exeception is

Any ideas or suggestions? Shouldn't SecureSocket.Send return if not in blocking mode?


Juan Pedro Martinez

SecurityOptions so = new SecurityOptions(SecureProtocol.Ssl3 | SecureProtocol.Tls1);
so.VerificationType = CredentialVerification.Manual;
so.AllowedAlgorithms = SslAlgorithms.SECURE_CIPHERS;
so.Flags = SecurityFlags.Default;
so.Entity = ConnectionEnd.Client;
so.CommonName ="";
so.Verifier = new CertVerifyEventHandler(OnVerify);
SecureSocket remote = new SecureSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, so);
remote.Connect (_remoteside);

remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Linger, lo);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, BUF_SIZE);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.SendBuffer, BUF_SIZE);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 1);
remote.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1);

... //Initialization

while (bMoreData)
if (localstream.DataAvailable)
read = localstream.Read (buffer,0, BUF_SIZE);
Console.Write ("sending {0}...", read);
remote.Send(buffer, 0, read, SocketFlags.None);


by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2003/09/24

> Shouldn't SecureSocket.Send return if not in blocking mode?

What do you exactly mean with "if not in blocking mode"? If you have changed the SecureSocket to a non-blocking socket [remote.Blocking = false;], do note that this is not supported. For a list of supported and unsupported functions, take a look at

If you need non-blocking behavior, you should use the asynchronous method calls [BeginSend/EndSend etc].

by Juan Pedro Martinez [jpmartinez at hubcc dot ca]
posted on 2003/09/26

I changed the code to BeginSend and now it doesn't block

I should have look to the source to see that the Blocking property doesn't work.


by Pieter Philippaerts [Pieter at mentalis dot org]
posted on 2003/09/26

Great to hear that it's working.
I think that the page from the documentation in the previous post is the only place where it's documented. I'll make sure to add it to the documentation of the unsupported methods also.


Copyright © 2002-2007, The Team. All rights reserved.
This site is located at
Send comments to the webmaster.