Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- try
- {
- TcpListener Server = new TcpListener(IPAddress.Any, 25565);
- Server.Start();
- Console.WriteLine("Server Started. Waiting for clients.");
- while (true)
- {
- if (Server.Pending())
- {
- TcpClient client = Server.AcceptTcpClient();
- NetworkStream stream = client.GetStream();
- byte[] buffer = new byte[20];
- buffer = Encoding.Default.GetBytes("Welcome");
- stream.Write(buffer, 0, buffer.Length);
- }
- else
- continue;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment