none
p2p application doesnt work well RRS feed

  • Question

  • hi

    lately im working on a p2p network as i found when i wanna build a connection between 2 node over internet & behind NAT  i have many HARD ways but i  selected Upnp and port forwarding .

    but when i test it it doesnt work with 2 different system .

    i`ve tested it (local host ) with my router ip and with forwarded port [ when i dont forward it doesnt work even on local host it make me sure about forwarding well and also port table in router setting (gateway) ] .

    Note : i add a new inbound rule in windows firewal [windows 7]  and i know it doesnt work with mobile network .

    [ it works with 2 system "router public ip & forwarded port" with a same router as my system and my Pc"

    i forward ports with Mono.Nat -version 1.2.24.0 but here i did it myself .

    its my simple socket code :

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Net;
    using System.Net.Sockets;
    
    
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            Socket client = null;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                try
                {
                    IPEndPoint endp = new IPEndPoint(IPAddress.Any, 12345);
                    server.Bind(endp);
                    server.Listen(1000);
                    server.Accept();
                    MessageBox.Show("connected");
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.ToString());
                }
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                try
                {
                    IPEndPoint endp = new IPEndPoint(IPAddress.Parse(textBox1.Text), 12345);
                    server.Connect(endp);
                    MessageBox.Show("connected");
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.ToString());
                }
            }
        }
    }
    

    i forwarded port 12345 and i insert server router ip myself .

    So i heard something as socketpermision and endpointpermission but i dont saw any same question solved with that . 

    sorry for poor english .

    Thanks in advance !

    Thursday, February 27, 2020 11:21 PM

All replies

  • Hi,
    WCF MSDN forum typically discuss and ask questions about general managed code networking topics such as serialization, System.NET, Windows Communication Foundation(WCF), and Web Services.
    It has nothing with the WCF topic. I suggest you post the question to Stackoverflow forum for tips.
    https://stackoverflow.com/
    Best Regards
    Abraham
    Friday, February 28, 2020 10:07 AM
    Moderator