title: Data transfer through internet
body: <p>I know this topic has been asked, i've used a lot of post from the internet like codeproject, stackoverflow, but i still can't transfer data between 2 computer not on LAN network.</p>
  
  <p>Is it different between transfer on  LAN or through internet? Do i have to have a temp sever to do this task? </p>
  
  <p>My program is working on LAN network but when i try to test program in WAN network, i setup the sever(receive) in my friend's computer that far from me, then, in my computer,in the client program,  i replaced the LAN's IP by the IP of my friend's computer, but it didn't work. Did i misunderstand anythings? </p>
  
  <p>If you don't understand me, please give me link of solution or teach me how to transfer data between 2 not on LAN computer. Thank you very much and sorry for my bad English.</p>
  
  <p>CODE: (only make the connection)</p>
  
  <p>Receive: (i set up this on my friend's machine)</p>
  
  <pre><code>namespace RecieveFile
  {
  public partial class Form1 : Form
  {
  #region Variables
      private Thread thrDownload;
      private Stream strLocal;
      private NetworkStream strRemote;
      private TcpListener tlsServer;
      #endregion
      public Form1()
      {
          InitializeComponent();
      }
      private void Form1_Load(object sender, EventArgs e)
      {            
          thrDownload = new Thread(StartRecieving);
          thrDownload.Start();
     }
      public void StartRecieving()
      {
          try
          {
              string hstServer = Dns.GetHostName();
              IPAddress ipaLocal = Dns.GetHostEntry(hstServer).AddressList[0];
              if (tlsServer == null)
              {
                  tlsServer = new TcpListener(IPAddress.Any, Convert.ToInt32(29250));                
  
              }
              tlsServer.Start();
  
              TcpClient tclServer = tlsServer.AcceptTcpClient();
              MessageBox.Show("Connection has been created");
          }
          catch (Exception e)
          {
              MessageBox.Show(e.Message);
          }
          finally
          {
              strLocal.Close();
              strRemote.Close();
              MessageBox.Show("In finally");
              StartRecieving();
          }
      }
   }
  }
  </code></pre>
  
  <p>Send: (i set up this in my machine)</p>
  
  <pre><code>private void Form1_Load(object sender, EventArgs e)
      {
       //171.255.9.234 is my friend's IP
       //if this ip is a ip of computer in my LAN network, it can work
          ConnectToSever("171.255.9.234", 29250);
  
      }
  public void ConnectToSever(string severIP, int severPort)
      {
          tcpClient = new TcpClient();
          try
          {
              tcpClient.Connect(severIP, severPort);
              MessageBox.Show("Connection has been created!","Message");
          }
          catch (Exception e)
          {
              MessageBox.Show(e.Message);
          }
      }
  </code></pre>