예제 #1
0
 static void Main(string[] args)
 {
     Console.Title = "RemoteServer";
     Server server = new Server(7000);
     Console.WriteLine("Сервер запущен.");
     while (true);
 }
예제 #2
0
 private static void Listen()
 {//Here we are waiting for new conections to come in and can deal with a moximium of 3 clients at the same time
     Socket Soc = null;
     printDebug("Start listen", true);
     try
     {
         listener = new TcpListener(Settings.Port);//When microsoft is not changing code they are crashing old programs 
         listener.Start();
         while (THListen != null)
         {
             Soc = listener.AcceptSocket();
             printDebug("Connect " + Soc.RemoteEndPoint.ToString(), true);
             string Msg = Settings.ScreenServerX + " " + Settings.ScreenServerY + " " + Screen.PrimaryScreen.Bounds.Width + " " + Screen.PrimaryScreen.Bounds.Height + " " + FirstConnect.ToString();
             FirstConnect = false;
             byte[] BMsg = ASCIIEncoding.ASCII.GetBytes(Msg);
             Soc.Send(BMsg, BMsg.Length, SocketFlags.None);
             if (Service1 == null || !Service1.Running) { Service1 = new Server(); Service1.Start(Settings.Port, Soc, Settings.ScreenServerX, Settings.ScreenServerY); }
             else if (Service2 == null || !Service2.Running) { Service2 = new Server(); Service2.Start(Settings.Port, Soc, Settings.ScreenServerX, Settings.ScreenServerY); }
             else if (Service3 == null || !Service3.Running) { Service3 = new Server(); Service3.Start(Settings.Port, Soc, Settings.ScreenServerX, Settings.ScreenServerY); }
         }
         listener.Stop();
     }
     catch (Exception Ex)
     {
         printDebug("Error listen " + Ex.Message, true);
     }
 }