Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. No connection could be made because the target machine actively refused it

No connection could be made because the target machine actively refused it

Scheduled Pinned Locked Moved C#
helptestingbeta-testingtoolsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M Riaz Bashir
    wrote on last edited by
    #1

    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(); }

    A 1 Reply Last reply
    0
    • M M Riaz Bashir

      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(); }

      A Offline
      A Offline
      aSarafian
      wrote on last edited by
      #2

      Possibly a firewall error or the target IP+port is not enabled.

      M 1 Reply Last reply
      0
      • A aSarafian

        Possibly a firewall error or the target IP+port is not enabled.

        M Offline
        M Offline
        M Riaz Bashir
        wrote on last edited by
        #3

        Thank you Mr Sarafian now i have sold my problem :) :rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups