O
O
Oleg Pogrebnyak2016-07-12 22:47:30
Data transfer
Oleg Pogrebnyak, 2016-07-12 22:47:30

Transferring data with closed ports?

There is a D-Link DIR-300NRU rev.B7 router.
Ports do not open: UPnP enabled, added virtual servers.
vRmxmpn.pngvKeNvfc.png
Saved, rebooted, no change. Also, just added to the firewall exceptions.
IQU7eUQ.png
I found the info that the torrent opens a certain port while it is running. I tried to send a message through an open port - 55585.
Server:

TcpListener server = null;
        try
        {
            Int32 port = 55585;
            IPAddress localAddr = IPAddress.Parse("127.0.0.1");
            server = new TcpListener(localAddr, port);
            server.Start();
            Byte[] bytes = new Byte[256];
            String data = null;
            while (true)
            {
                Console.Write("Waiting for a connection... ");
                TcpClient client = server.AcceptTcpClient();
                Console.WriteLine("Connected!");
                data = null;
                NetworkStream stream = client.GetStream();
                int i;
                while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
                {
                    data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
                    Console.WriteLine("Received: {0}", data);
                    byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
                    stream.Write(msg, 0, msg.Length);
                    Console.WriteLine("Sent: {0}", data);
                }
                client.Close();
            }
        }
        catch (SocketException e)
        {
            Console.WriteLine("SocketException: {0}", e);
        }
        finally
        {
            server.Stop();
        }
        Console.WriteLine("\nHit enter to continue...");
        Console.Read();

Customer:
static void Main(string[] args)
        {
            try
            {
                string tmp1 = Console.ReadLine();
                string tmp = Console.ReadLine();
                Connect(tmp1, tmp);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                Console.ReadLine();
            }
        }

        static void Connect(String server, String message)
        {
            try
            {
                Int32 port = 55585;
                TcpClient client = new TcpClient(server, port);
                Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
                NetworkStream stream = client.GetStream();
                stream.Write(data, 0, data.Length);
                Console.WriteLine("Sent: {0}", message);
                data = new Byte[256];
                String responseData = String.Empty;
                Int32 bytes = stream.Read(data, 0, data.Length);
                responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
                Console.WriteLine("Received: {0}", responseData);
                stream.Close();
                client.Close();
            }
            catch (ArgumentNullException e)
            {
                Console.WriteLine("ArgumentNullException: {0}", e);
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }

            Console.WriteLine("\n Press Enter to continue...");
            Console.Read();
        }

Naturally, I tried via UDP and different sources on the network, the same result:
It works through localhost regardless of the port, which was expected.
qnTHS9p.png
If I enter a valid address, I get a refusal.
F2MpMv1.png
Are there any viable options for opening a port or transferring data without using the latter?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zelimkhan Beltoev, 2016-07-13
@Beltoev

Am I missing something or have you opened 27015 on the router for external connections, but are you trying to connect to port 55585 from the outside?
Well, judging by the screenshot, you are forwarding the ports incorrectly: if you need access to the computer's port 55585 from the outside, add it in the "Internal port" field in the router. And try to connect to an external port (you have it 27015).
Is 192.168.0.100 exactly the IP of the computer on the internal network?

A
ar4ebaldello, 2016-07-13
@ar4ebaldello

For these purposes, there is a special service - ngrok

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question