Advertisement
gtdany7

Untitled

Jun 4th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1.  static void Main(string[] args)
  2.         {
  3.             Socket soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  4.             IPEndPoint ipEnd = new IPEndPoint(IPAddress.Any, 6000);
  5.  
  6.  
  7.             // -----TIMEOUT----------------------------------
  8.             Stopwatch stopWatch = new Stopwatch();
  9.             stopWatch.Start();
  10.             Thread.Sleep(1000); //1s reais = 1min virtuais de timing para aparecer !!
  11.             stopWatch.Stop();
  12.             // Get the elapsed time as a TimeSpan value.
  13.             TimeSpan ts = stopWatch.Elapsed;
  14.  
  15.             // Format and display the TimeSpan value.
  16.             string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
  17.                 ts.Hours, ts.Minutes, ts.Seconds,
  18.                 ts.Milliseconds / 10);
  19.             Console.WriteLine("RunTime :" +"["+elapsedTime+"]");
  20.  
  21.             soc.Bind(ipEnd);
  22.             soc.Listen(10);
  23.  
  24.             Console.WriteLine("•——————————————• Bem Vindo ao SCV •——————————————•");
  25.  
  26.             do
  27.             {
  28.  
  29.                 Socket soc_new = soc.Accept();
  30.                 IPEndPoint ipEnd_new = (IPEndPoint)soc_new.RemoteEndPoint;
  31.  
  32.                 LigacaoTerminal connection = new LigacaoTerminal(soc_new, ipEnd_new);
  33.                 Thread newThread = new Thread(new ThreadStart(connection.ReceiveFromTerminal));
  34.                 Thread newThread2 = new Thread(new ThreadStart(connection.ReceiveFromSRE));
  35.  
  36.                 newThread.Start();
  37.                 newThread2.Start();
  38.                
  39.             } while (true);
  40.  
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement