title: UDP Address already in use?
body: <p>I am following the UDP tutorials at <a href="http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html" rel="noreferrer">http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html</a> ,I have copied all the code and compiled it, now If I compile the client first and then the server, the server prints this out in console</p>
  
  <pre><code>Exception in thread "main" java.net.BindException: Address already in use: Cannot bind
  at java.net.PlainDatagramSocketImpl.bind0(Native Method)
  at java.net.PlainDatagramSocketImpl.bind(Unknown Source)
  at java.net.DatagramSocket.bind(Unknown Source)
  at java.net.DatagramSocket.&lt;init&gt;(Unknown Source)
  at java.net.DatagramSocket.&lt;init&gt;(Unknown Source)
  at java.net.DatagramSocket.&lt;init&gt;(Unknown Source)
  at QuoteServerThread.&lt;init&gt;(QuoteServerThread.java:19)
  at MulticastServerThread.&lt;init&gt;(MulticastServerThread.java:10)
  at MulticastServer.main(MulticastServer.java:3)
  </code></pre>
  
  <p>QuoteServerThread line 19 is </p>
  
  <pre><code>socket = new DatagramSocket(12345);
  </code></pre>
  
  <p>MulticastServerThread line 10 is</p>
  
  <pre><code>public MulticastServerThread() throws IOException {
      super("MulticastServerThread"); // line 10
  }
  </code></pre>
  
  <p>MulticastServer line 3 is</p>
  
  <pre><code>public class MulticastServer {
      public static void main(String[] args) throws java.io.IOException {
          new MulticastServerThread().start(); // line 3
      }
  }
  </code></pre>
  
  <p>If I start the server first, then the client, the client prints out this in console</p>
  
  <pre><code>Exception in thread "main" java.net.BindException: Address already in use: Cannot bind
  at java.net.PlainDatagramSocketImpl.bind0(Native Method)
  at java.net.PlainDatagramSocketImpl.bind(Unknown Source)
  at java.net.DatagramSocket.bind(Unknown Source)
  at java.net.MulticastSocket.&lt;init&gt;(Unknown Source)
  at java.net.MulticastSocket.&lt;init&gt;(Unknown Source)
  at MulticastClient.main(MulticastClient.java:9)
  </code></pre>
  
  <p>MulticastClient line 9 is</p>
  
  <pre><code>MulticastSocket socket = new MulticastSocket(12345);
  </code></pre>
  
  <p>Looking at the errors, it seems to me that it is something to do with listening to ports, how can I go about fixing this?</p>
  
  <p>Canvas</p>