title: How to get the example MulticastChat operational?
body: <p>I have so far defined the port number and inetaddress but I still can't understand why I fail to get the example below to present a GUI? I would be appreciated if someone in the community can point out the mistake I am making. Thank you.</p>
  
  <p>Below is the source code of the complete program for the Multicasting in the GUI format that uses the peer to peer network implementation by passing messages with the TCP protocol and implements multithreading using the synchronized method to send messages to all peers connected thus far. </p>
  
  <pre><code>/* Multicast Peer to Peer chat application that uses TCP protocol to chat 
   * to two users at a time or adding more clients could be developed into 
   * a group chat communicating amongst multiple members of the same chat. 
   *
  */
  
  import java.io.*;
  import java.net.*;
  import java.awt.*;
  import java.awt.event.*;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  public final class MulticastChat implements Runnable, WindowListener, ActionListener {
     protected InetAddress group;
     protected int port = 2343;
  
    public MulticastChat (InetAddress group, int port) {
       this.group = group;
       this.port = port;
       initAWT();
     }
  
     protected Frame frame;
     protected TextArea output;
     protected TextField input;
     private static final Logger logger =
        Logger.getLogger(MulticastChat.class.getName());
  
  
     protected void initAWT () {
       frame = new Frame
         ("MulticastChat [" + group.getHostAddress () + ":" + port + "]");
       frame.addWindowListener (this);
       output = new TextArea ();
       output.setEditable (false);
       input = new TextField ();
       input.addActionListener (this);
       frame.setLayout (new BorderLayout ());
       frame.add (output, "Center");
       frame.add (input, "South");
       frame.pack ();
     }
  
      protected Thread listener;
  
      public synchronized void start() throws IOException {
       if (listener == null) {
         initNet ();
         listener = new Thread (this);
         listener.start ();
         frame.setVisible (true);
       }
     }
  
     protected MulticastSocket socket;
     protected DatagramPacket outgoing, incoming;
  
     protected void initNet () throws IOException {
       socket = new MulticastSocket (port);
       socket.setTimeToLive (5);
       socket.joinGroup (group);
       outgoing = new DatagramPacket (new byte[1], 1, group, port);
       incoming = new DatagramPacket (new byte[65508], 65508);
     }
  
     public synchronized void stop () throws IOException {
       frame.setVisible (false);
       if (listener != null) {
         listener.interrupt ();
         listener = null;
         try {
           socket.leaveGroup (group);
         } finally {
           socket.close ();
         }
       }
     }
  
     @Override
     public void windowOpened (WindowEvent event) {
       input.requestFocus ();
     }
  
     @Override
     public void windowClosing (WindowEvent event) {
       try {
         stop ();
       } catch (IOException ex) {
             logger.log(Level.WARNING,"WindowClosing IOException",ex);
       }
     }
  
     @Override
     public void windowClosed (WindowEvent event) {}
     @Override
     public void windowIconified (WindowEvent event) {}
     @Override
     public void windowDeiconified (WindowEvent event) {}
     @Override
     public void windowActivated (WindowEvent event) {}
     @Override
     public void windowDeactivated (WindowEvent event) {}
  
     @Override
     public void actionPerformed (ActionEvent event) {
       try {
         byte[] utf = event.getActionCommand ().getBytes ("UTF8");
         outgoing.setData (utf);
         outgoing.setLength (utf.length);
         socket.send (outgoing);
         input.setText ("");
       } catch (IOException ex) {
         handleIOException (ex);
       }
     }
  
     protected synchronized void handleIOException (IOException ex) {
       if (listener != null) {
         output.append (ex + "\n");
         input.setVisible (false);
         frame.validate ();
         if (listener != Thread.currentThread ())
           listener.interrupt ();
         listener = null;
         try {
           socket.leaveGroup (group);
         } catch (IOException ignored) {
         }
         socket.close ();
       }
     }
  
     @Override
     public void run () {
       try {
         while (!Thread.interrupted ()) {
           incoming.setLength (incoming.getData ().length);
           socket.receive (incoming);
           String message = new String
             (incoming.getData (), 0, incoming.getLength (), "UTF8");
           output.append (message + "\n");
         }
       } catch (IOException ex) {
          handleIOException (ex);
       }
     }
  
  // Unfortunately the example given didn't have any comments for me to try 
  // to understand how to get the example operating. 
     public static void main (String[] args) throws IOException {
       if ((args.length != 1) || (!args[0].contains(":"))){
         throw new IllegalArgumentException
           ("Syntax: MulticastChat &lt;group&gt;:&lt;port&gt;");
       } else {
  
      int idx = args[0].indexOf (":");
         InetAddress group = InetAddress.getByName (args[0].substring (0, idx));
       int port = Integer.parseInt (args[0].substring (idx + 1));
  
      MulticastChat chat = new MulticastChat (group, port);
                  chat.start();
         }
       }
     }
  </code></pre>
  
  <p>Here is the error presented:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Syntax: MulticastChat &lt;group&gt;:&lt;port&gt;
  at MulticastChat.main(MulticastChat.java:167)
  </code></pre>