Zachman61

Untitled

Nov 12th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             try
  4.             {
  5.                 TcpListener Server = new TcpListener(IPAddress.Any, 25565);
  6.                 Server.Start();
  7.                 Console.WriteLine("Server Started. Waiting for clients.");
  8.  
  9.                 while (true)
  10.                 {
  11.                     if (Server.Pending())
  12.                     {
  13.                         TcpClient client = Server.AcceptTcpClient();
  14.                         NetworkStream stream = client.GetStream();
  15.                         byte[] buffer = new byte[20];
  16.                         buffer = Encoding.Default.GetBytes("Welcome");
  17.                         stream.Write(buffer, 0, buffer.Length);
  18.                     }
  19.                     else
  20.                         continue;
  21.                 }
  22.             }
  23.             catch (Exception ex)
  24.             {
  25.                 Console.WriteLine(ex.Message);
  26.                 Console.ReadKey();
  27.             }
  28.         }
Advertisement
Add Comment
Please, Sign In to add comment