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! |