Example #1
0
        public void AcceptCallback(IAsyncResult ar)
        {
            if (mClient != null)
            {
                mClient.close();//close working session
            }
            Socket listener = (Socket)ar.AsyncState;
            Socket handler  = listener.EndAccept(ar);

            mClient = new ClientAgent(handler, this); //only one working client
            mClient.startReceive();
            mConnectCounter++;
            AsyncCallback aCallback = new AsyncCallback(AcceptCallback);

            mListener.BeginAccept(aCallback, mListener);
        }
 public void AcceptCallback(IAsyncResult ar)
 {
     if (mClient != null){
         mClient.close();//close working session
     }
     Socket listener = (Socket)ar.AsyncState;
     Socket handler = listener.EndAccept(ar);
     mClient = new ClientAgent(handler,this); //only one working client
     mClient.startReceive();
     mConnectCounter++;
     AsyncCallback aCallback = new AsyncCallback(AcceptCallback);
     mListener.BeginAccept(aCallback, mListener);
 }