Ejemplo n.º 1
0
 /// <summary>
 /// Starts a new thread for listening to incoming messages
 /// </summary>
 public void Connect()
 {
     try
     {
         form.AddMessage("[client]: Connecting...");
         Task.Run(() => ReceiveData(this));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         form.AddMessage("[server]: Connection failed, please try again.");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Starts the server class so clients can connect to it
 /// </summary>
 public void Start()
 {
     try
     {
         listener = new TcpListener(IPAddress.Any, port);
         listener.Start();
         Listen();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         form.AddMessage("[client]: Another server is already running!");
         form.SetButtons(true, true);
     }
 }