private void Form1_Load(object sender, EventArgs e) { CheckForIllegalCrossThreadCalls = false; button3.Enabled = false; textBox3.Text = Environment.CurrentDirectory; /**** Auto create the connection to server ****/ // Try to connect to the server try { // get ip address String ip = "127.0.100.6"; // get port number int port = 6060; client.ConnectToServer(ip, port); Thread t = new Thread(Listener); t.Start(); } catch { // if connecting is failed the turn on the offline mode MessageBox.Show("You are offline now!"); return; } }
public void Connect() { string ip = "127.0.0.1"; int port = 13000; tcpForPlayer = new TCPModel(ip, port); tcpForPlayer.ConnectToServer(); this.Text = tcpForPlayer.UpdateInformation(); tcpForOpponent = new TCPModel(ip, port); tcpForOpponent.ConnectToServer(); }
public void DetectServer() { string ip = "127.0.0.1"; tcpForChoosingServer = new TCPModel(ip, port); tcpForChoosingServer.ConnectToServer(); string str = tcpForChoosingServer.ReadData(); port = int.Parse(str); Console.WriteLine("Port la: " + port); }
public void Connect() { string ip = "127.0.0.1"; tcpForPlayer = new TCPModel(ip, port); if (tcpForPlayer.ConnectToServer() == -1) { return; } this.Text = tcpForPlayer.UpdateInformation(); t = new Thread(Commmunication); t.IsBackground = true; t.Start(); //tcpForOpponent = new TCPModel(ip, port); //tcpForOpponent.ConnectToServer(); }