title: Transfer a String from 1 program to another via Network in C#
body: <p>Simple Concept. I have a string on computer A, I want it moved to computer B, how to do it, why is it so complex :)</p>
  
  <p>I am setting up a program I need to run on multiple PC's where the different nodes needs to communicate. What needs to be sent is a text string (a command object that has been serialized to a string). Some of these nodes might be "clients" behind a firewall so how do they initiate two-way communication so they can receive information back once connected up?</p>
  
  <p>My expectations would be that seen outside this transfer part that you have an entry point and a pickup point. Following is how I see the pseudocode, but I simply do not understand network coding well enough to figure out how it actually works to get it right. So far my searching has left me with code I do not understand what does, or the idea behind. (see questions after code)</p>
  
  <pre><code>public void SendCommand(String commandObject, String targetService)
  {
      &lt;lookup service address&gt;
      &lt;connect to address&gt;  || &lt;connect to address if not already connected&gt;
      &lt;send string&gt;
      &lt;close connection&gt;  || &lt;keep connection open&gt;
  }
  
  public List&lt;String&gt; GetCommands()
  {
      &lt;Grab Mutex on Outbox&gt;
          &lt;Copy Outbox to tmpList&gt;
          &lt;empty Outbox List&gt;
      &lt;release Mutex&gt;
      &lt;return tmpList&gt;
  }
  </code></pre>
  
  <p>??? how to handle this</p>
  
  <pre><code>    &lt;accept connection&gt;
      &lt;receive string and move it to local buffer List&lt;String&gt; DropOff&gt;
      &lt;get mutex via (waitOne(0)) for access to List&lt;String&gt; Outbox
          &lt;move DropOff entries to Outbox&gt;
          &lt;empty DropOff&gt;
      &lt;release Mutex&gt;
  </code></pre>
  
  <p>Here my understanding fails.</p>
  
  <p>*I do not understand how the Receive part of the network code is, and get the entry into the "DropOff" in a way that does not risk issues with multiple threads (hence idea of DropOff and Outbox in this code, is this already handled?)</p>
  
  <p>*I do not understand how to setup a client to connect to this network layer in a way so twoway communication can occour. (Here I do understand its both computers having a listener and a way to send to the others sender, but if the listener on the Client computer is behind a firewall, how do I send replies and setup this listener once connection between the two computers have been established?)</p>
  
  <p>I believe these are questions that have been asked quite a few times before, but I simply do not understand this well enough to know what to search for to get the required understanding. If you could direct me to this, and also help my understanding if my understanding of the pseudo code setup is wrong, please do so.</p>