No connection could be made because the target machine actively refused it
-
Hi, kindly check my little script and tell me. where am I doing wrong? When i run this script the error arises : ==>> No connection could be made because the target machine actively refused it thank you private void button1_Click(object sender, EventArgs e) { IPAddress host = IPAddress.Parse("192.168.0.102"); // <<-- my machine ip IPEndPoint hostep = new IPEndPoint(host, 8000); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { sock.Connect(hostep); // <== Error comes from here listBox1.Items.Add("Connected."); } catch (Exception ex) { listBox1.Items.Add("Connection problem is :"); listBox1.Items.Add(ex.Message); textBox1.Text = ex.Message; sock.Close(); return; } try { sock.Send(Encoding.ASCII.GetBytes("testing")); } catch (Exception exsoc) { listBox1.Items.Add("Problem sending data"); listBox1.Items.Add(exsoc.Message); sock.Close(); return; } sock.Close(); }
-
Hi, kindly check my little script and tell me. where am I doing wrong? When i run this script the error arises : ==>> No connection could be made because the target machine actively refused it thank you private void button1_Click(object sender, EventArgs e) { IPAddress host = IPAddress.Parse("192.168.0.102"); // <<-- my machine ip IPEndPoint hostep = new IPEndPoint(host, 8000); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { sock.Connect(hostep); // <== Error comes from here listBox1.Items.Add("Connected."); } catch (Exception ex) { listBox1.Items.Add("Connection problem is :"); listBox1.Items.Add(ex.Message); textBox1.Text = ex.Message; sock.Close(); return; } try { sock.Send(Encoding.ASCII.GetBytes("testing")); } catch (Exception exsoc) { listBox1.Items.Add("Problem sending data"); listBox1.Items.Add(exsoc.Message); sock.Close(); return; } sock.Close(); }
-
Thank you Mr Sarafian now i have sold my problem :) :rose: