Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ExtListen
- {
- // Fields
- public static char ch;
- // Methods
- public static void Cnt()
- {
- try
- {
- Socket socket = Netplay.tcpListener.AcceptSocket();
- Console.WriteLine("Connection accepted from " + socket.RemoteEndPoint);
- byte[] buffer = new byte[100];
- int num = socket.Receive(buffer);
- Console.WriteLine("Recieved...");
- for (int i = 0; i < num; i++)
- {
- ch = Convert.ToChar(buffer[i]);
- }
- Main.text = ch.ToString();
- ASCIIEncoding encoding = new ASCIIEncoding();
- socket.Send(encoding.GetBytes("The string was recieved by the server."));
- Console.WriteLine("\nSent Acknowledgement");
- socket.Close();
- Netplay.tcpListener.Stop();
- }
- catch (Exception exception)
- {
- Console.WriteLine("Error..... " + exception.StackTrace);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment