1

hi every one and thanks in advance please forgive my poor level in english but i want some help : my probleme is that i'm trying to make an application that send bytes over the Intenet and whene ever i try to connect it says : connections could not be done machine actvely refused IP:PORT

keep in minde :

  • the application works whene i try to connect with "127.0.0.1"
  • fire wall is off
  • port open.Whene i run "NetStat -an" command in CMD it shows my app like this 0000:Port LISTENING wich mean the server is listning
  • both the server and the client uses the same port

and this is the code for the Server

 public static void start()
    {
        SocketPermission permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp,"", SocketPermission.AllPorts);

        sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, Settings.Protcole);
        permission.Demand();
        IPEndPoint end = new IPEndPoint(IPAddress.Any, Settings.Port);
        sock.Bind(end);
            sock.Listen(10);
            accepted = sock.Accept();
            Connected = true;
        }

and this is the code for the client

 public static void Connect(string IP)
    {
        try
        {
            SocketPermission permission = new SocketPermission(NetworkAccess.Accept, TransportType.Tcp, Server.GetIP(), SocketPermission.AllPorts);
            sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, Settings.Protcole);
            permission.Demand();
            IPEndPoint end = new IPEndPoint(IPAddress.Parse(IP), Settings.Port);
            sock.Connect(end);
            Connected = true;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "O.o", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
Youness
  • 1,468
  • 1
  • 9
  • 19
  • 1
    Actively refused is a connection issue.. not a code issue. The port being opened is one thing.. is it forwarded to whatever device internally it needs to be forwarded to? – Simon Whitehead Aug 26 '13 at 00:35
  • http://stackoverflow.com/questions/9695224/no-connection-could-be-made-because-the-target-machine-actively-refused-it-127-0 - possible duplicate – Na Na Aug 26 '13 at 01:01
  • soory but the port is open and my process (server) is listening and @NaNa it's not a duplicate i tryed evry thing and it's still not working it only work on LAN – Youness Aug 26 '13 at 19:11

0 Answers0