public void DetectServer() { tcptochooseServer = new TCPModel(IP, port); tcptochooseServer.ConnectToServer(); string Port = tcptochooseServer.ReadData(); port = int.Parse(Port); }
public int Connect() { try { tcpforplayer = new TCPModel(IP, port); int error = tcpforplayer.ConnectToServer(); if (error == -1) { port = 8080; // port root server Connect(); } else { this.Text = tcpforplayer.UpdateInformation(); tcpforOpponent = new TCPModel(IP, port); tcpforOpponent.ConnectToServer(); } } catch (Exception e) { Console.WriteLine("ERROR......" + e.StackTrace); return(-1); } return(1); }