by Juan Pedro Martinez [jpmartinez at hubcc dot ca] posted on 2003/09/24 |
|
Hello,
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
thrown.
Any ideas or suggestions? Shouldn't SecureSocket.Send return if not in blocking mode?
Thanks,
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.Certificate=null;
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);
Console.Write("sent");
}
.....
} |
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 http://www.mentalis.org/soft/projects/seclib/docs/ssl_todo.html
If you need non-blocking behavior, you should use the asynchronous method calls [BeginSend/EndSend etc]. |