Grazie per l'interessamento![]()
allora adesso ti posto il codice che estratto a parte:
e con le classi TcpListener e TcpClient ma il risultato è medesimo anche con le classi Socket;Codice PHP:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
class TCP
{
public static string GetRemoteIP()
{
try
{
string whatIsMyIp = "http://www.whatismyip.com/automation/n09230945.asp";
WebClient wc = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
string requestHtml = "";
requestHtml = utf8.GetString(wc.DownloadData(whatIsMyIp));
IPAddress externalIp = null;
externalIp = IPAddress.Parse(requestHtml);
string string_externalIp = externalIp.ToString();
return string_externalIp;
}
catch
{
return null;
}
}
public static void accConn()
{
TcpListener listener = new TcpListener(IPAddress.Any, 7000);
Console.WriteLine(GetRemoteIP());
listener.Start();
listener.AcceptSocket();
Console.WriteLine("Connessione ACCETTATA!!!");
Console.ReadKey();
}
public static void Conn()
{
IPAddress remoteIP = IPAddress.Parse(GetRemoteIP());
TcpClient client = new TcpClient();
client.Connect(GetRemoteIP(), 7000);
Console.WriteLine("Connessione EFFETTUATA!!!");
Console.ReadKey();
}
}
static void Main(string[] args)
{
Thread listener = new Thread(TCP.accConn);
Thread client = new Thread(TCP.Conn);
listener.Start();
Console.WriteLine("Listener avviato");
client.Start();
Console.WriteLine("Client avviato");
Console.ReadKey();
}
}
}
ora sto "riparando" il sistema per aggiungere TELNET a windows 7,
mi potresti spiegare il discorso del router dato che io eseguo il test con il mio pc collegato al router collegato a sua volta in internet?

