so here, you get an IAsyncResult reference:
PHP Code:
IAsyncResult asyncSkt = m_socListener.BeginAccept(new AsyncCallback(OnClientConnect), null);
here you add your IAsyncResult reference to a hashtable:
PHP Code:
sockettable.Add(connectId, asyncSkt);
and then finally you try to cast an IAsyncResult reference to a Socket:
PHP Code:
Socket socket = ( Socket)sockettable[connectId];
You end up with an InvalidCastException because you can't cast an IAsyncResult to a Socket. Maybe reading up on asynchronous programming willhelp you out.