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
 
BUG?: Accept does not work when used in a WaitCallback?  
by J.R. Brown [jbrown at les dot com]
posted on 2004/02/11

Here's whats happening...first the code in the order its called. (snips)

private SecureSocket _socket;
private WaitCallback _onStart;



public void Start() {
_onStart = new WaitCallback(OnStart);

if (_started)
throw new InvalidOperationException();

SecureProtocol sp;
sp = SecureProtocol.Ssl3;

CertificateStore cs;
cs = CertificateStore.CreateFromPfxFile("server.pfx", "test");
Certificate cert = cs.FindCertificateByUsage( new string[] {"1.3.6.1.5.5.7.3.1"});

SecurityOptions options = new SecurityOptions(sp, cert, ConnectionEnd.Server);
SecureSocket _socket = new SecureSocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, options);

_socket.Bind(new IPEndPoint(IPAddress.Any, _port));
_socket.Listen((int)SocketOptionName.MaxConnections);

_started = true;
ThreadPool.QueueUserWorkItem(_onStart);
}



private void OnStart(Object unused) {
while (_started) {
try {
SecureSocket socket = (SecureSocket)_socket.Accept(); //*** THIS IS THE PROBLEM LINE ***
ThreadPool.QueueUserWorkItem(_onSocketAccept, socket);
}
catch {
Thread.Sleep(100);
}
}

_stopped = true;
}


OK, I've been racking my brain over this with little success. Note, everything runs appears to run fine with no error messages. The interesting thing I've found is that the line marked with //*** works fine if I am using regular sockets, I have set my breakpoint set on this line and I see in the (autos) that _socket has a value associated with it. The problem is when this socket is a SecureSocket as is above, my value returned is <undefined value>.

PLEASE HELP!

 

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