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.BeginSend() Excepts in the wrong circumstances  
by Alfonso Ferrandez
posted on 2005/04/25

Similar to kaalikas comments on Send(), the asynchronous version BeginSend() actually excepts with an ArgumentException if the size of the data is zero. This should not be the case since for example the FTP protocol needs to send zero size data packets to signify a directory is empty after sending a LIST command.

I've commented out the lines below and everything works as expected now. Notice that the definition of the Socket class in MSDN explicitly says that an exception will only occur if size < 0 precisely because the reason given above.

Cheers!
AL

---- Modified BeginSend()------
public override IAsyncResult BeginSend(byte[] buffer, int offset, int size, SocketFlags socketFlags, AsyncCallback callback, object state) {
if (SecureProtocol == SecureProtocol.None)
return base.BeginSend(buffer, offset, size, socketFlags, callback, state);
if (!Connected)
throw new SocketException();
if (buffer == null)
throw new ArgumentNullException();
// if (size == 0)
// throw new ArgumentException();
if (offset < 0 || offset >= buffer.Length || size > buffer.Length - offset || size < 0)
throw new ArgumentOutOfRangeException();
// begin secure send
return m_Controller.BeginSend(buffer, offset, size, callback, state);
}

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.