title: Sockets and DatagramChannels
body: <p>I am trying to write a piece of software that </p>
  
  <ul>
  <li>accept simple UDP messages (text strings) from simple UDP client, </li>
  <li>opens connection to another server and forwards messages to it</li>
  <li>listens for that server reply and </li>
  <li>forwards that reply back to the client. </li>
  </ul>
  
  <p>So it is a simple intermediate server. </p>
  
  <p>To visualise the communication:</p>
  
  <p>Client &lt;---> Intermediate Server &lt;---> "Real" Server</p>
  
  <p>The client connects to the Intermediate but has no idea that the message it sends is being forwarded to another server, or that it's reply is actually from another server. As far as the client cares it the Intermediate server is the real server.</p>
  
  <p>I am trying to use Java's DatagramChannel for this, but not quite sure how to correctly do this in a non-hack way. Do I use two DatagramChannels? One for Client--Intermediate and the other for Intermediate--Real Server?</p>
  
  <p>An general outline of approach would be appreciated, particularly if I need to open a socket every time I need to forward a message from the Intermediate to the Real Server, or if I can keep that socket open somehow.</p>