示例#1
0
        private void NewConnection(ISocket sock)
        {
            try
            {
                /*
                 *  if (listener.State == SocketState.Closed || listener.State == SocketState.Terminated)
                 *  {
                 *         Console.WriteLine("Listen socket break ");
                 *         Console.WriteLine(listener.LocalEndPoint.Port);
                 *         break;
                 *  }
                 */

                if (sock == null)
                {
                    //Console.Write("sock == null");
                    return;
                }

                //sock.ReceiveBufferSize = 102400;
                //sock.SendBufferSize = 102400;


                TConnection c = new TConnection();
                AddConnection(c);

                c.Assign(sock);

                ClientConnected(c);

                // Accept more
                listener.Accept().Then(NewConnection);

                sock.Begin();
            }
            catch (Exception ex)
            {
                //Console.WriteLine("TSERVER " + ex.ToString());
                Global.Log("NetworkServer", LogType.Error, ex.ToString());
            }

            //isRunning = false;
        }
示例#2
0
 public bool Begin()
 {
     return(sock.Begin());
 }