Deathmax

Untitled

Dec 12th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. public class ExtListen
  2. {
  3.     // Fields
  4.     public static char ch;
  5.  
  6.     // Methods
  7.     public static void Cnt()
  8.     {
  9.         try
  10.         {
  11.             Socket socket = Netplay.tcpListener.AcceptSocket();
  12.             Console.WriteLine("Connection accepted from " + socket.RemoteEndPoint);
  13.             byte[] buffer = new byte[100];
  14.             int num = socket.Receive(buffer);
  15.             Console.WriteLine("Recieved...");
  16.             for (int i = 0; i < num; i++)
  17.             {
  18.                 ch = Convert.ToChar(buffer[i]);
  19.             }
  20.             Main.text = ch.ToString();
  21.             ASCIIEncoding encoding = new ASCIIEncoding();
  22.             socket.Send(encoding.GetBytes("The string was recieved by the server."));
  23.             Console.WriteLine("\nSent Acknowledgement");
  24.             socket.Close();
  25.             Netplay.tcpListener.Stop();
  26.         }
  27.         catch (Exception exception)
  28.         {
  29.             Console.WriteLine("Error..... " + exception.StackTrace);
  30.         }
  31.     }
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment