Ciao a tutti.
sto testando una semplice applicazione per inviare stringhe tramite il protocollo tcp, in rete locale funziona tutto perfettamente, quando invece provo in internet mi esce l'errore Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione.
Premetto che ho aperto la porta nel router, ho controllato anche digitando netstat -a, e viene segnata su LISTENING.
ho provato anche con TELNET ip porta e mi dice impossibile aprire una connessione con l'host..
da cosa può dipendere?

SERVER:
codice:
string host = Dns.GetHostName();
IPAddress[] ip = Dns.GetHostAddresses(host);

Console.WriteLine("Host: " + ip[0].ToString());
TcpListener listener = new TcpListener(ip[0], 31135);
listener.Start();

Console.WriteLine("Wait for call...");
Socket s = listener.AcceptSocket();

NetworkStream nt = new NetworkStream(s);
byte[] strLength = new byte[1], buffer;
while (true)
{
       try
       {
             nt.Read(strLength, 0, 1);
             buffer = new byte[(int)strLength[0]];
             nt.Read(buffer, 0, buffer.Length);
             Console.WriteLine(Encoding.ASCII.GetString(buffer));
        }
        catch { break; }
}

s.Close();
Console.WriteLine("Connection Closed\nPress any key to quit.");
Console.Read();
CLIENT
codice:
TcpClient client = new TcpClient();

Console.WriteLine("Please Wait...");
IPAddress ip = getWanIp();
client.Connect(ip, 31135);
Console.WriteLine("Ready.");

NetworkStream nt = client.GetStream();
byte[] strLength = new byte[1], buffer;
while (true)
{
        try
        {
              buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(Console.ReadLine());
              strLength[0] = (byte)buffer.Length;
              nt.Write(strLength, 0, 1);
              nt.Write(buffer, 0, buffer.Length);
         }
         catch { }
}

private static IPAddress getWanIp()
{
        WebClient wc = new WebClient();
        string ip = Encoding.ASCII.GetString((wc.DownloadData("http://whatismyip.com/automation/n09230945.asp")));
        wc.Dispose();
        return IPAddress.Parse(ip);
}