News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
SecureSocket.Send blocks  
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].

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.

Thanks

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 Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.