Heylo

I have written a code for reliable multicast for client and server. The client is receiving only few packets sent by the server.Can I implement this using threads?Please HELP ME!!!!!.Thanks in advance.

This is the client program

import java.io.*;
import java.net.*;

import javax.swing.*;
public class QuoteMultiClient
{

public static JButton B_CONNECT = new JButton("CONNECT");
public static JFrame MainWindow=new JFrame("DatagamQuote");
public static JScrollPane SP_OUTPUT=new JScrollPane();
public static JTextArea TA_OUTPUT=new JTextArea();
static int time=5000;
public static void main(String[] args) throws Exception
{

BuildGui();

}


public static void CONNECT()
{
try
{

MulticastSocket SOCK=new MulticastSocket(208);
InetAddress IP_ADDRESS=InetAddress.getByName("224.0.0.0");
SOCK.joinGroup(IP_ADDRESS);
DatagramPacket PACKET;


//DatagramPacket ACK;
for(int i=0;i<6;i++)
{
byte[] buf = new byte[256];
PACKET = new DatagramPacket(buf,buf.length);
SOCK.receive(PACKET);
String MESSAGE=new String(PACKET.getData(),0,PACKET.getLength());
TA_OUTPUT.append("\n \n Todays Quote" + MESSAGE);




}



SOCK.leaveGroup(IP_ADDRESS);
SOCK.close();
}
catch(IOException X)
{
System.out.println(X);
}
}
public static void BuildGui()
{
MainWindow.setSize(410,280);
MainWindow.setLocation(200,200);
MainWindow.setResizable(false);
MainWindow.setBackground(new java.awt.Color(255,255,255));
MainWindow.getContentPane().setLayout(null);
B_CONNECT.setBackground(new java.awt.Color(0,0,255));
B_CONNECT.setForeground(new java.awt.Color(255,255,255));
MainWindow.getContentPane().add(B_CONNECT);
B_CONNECT.setBounds(150,15,110,25);
TA_OUTPUT.setLineWrap(true);
SP_OUTPUT.setHorizontalScrollBarPolicy(ScrollPaneC onstants.HORIZONTAL_SCROLLBAR_NEVER);
SP_OUTPUT.setVerticalScrollBarPolicy(ScrollPaneCon stants.VERTICAL_SCROLLBAR_ALWAYS);
SP_OUTPUT.setViewportView(TA_OUTPUT);
MainWindow.getContentPane().add(SP_OUTPUT);
SP_OUTPUT.setBounds(10,45,380,180);
//MainWindow_Action();
MainWindow.setVisible(true);
MainWindow_Action();
}

public static void MainWindow_Action()
{



B_CONNECT.addActionListener(
new java.awt.event.ActionListener()
{

public void actionPerformed(java.awt.event.ActionEvent evt)
{


CONNECT();
}

}




);

}
}

This is the server code

import java.io.*;
import java.net.*;
import java.util.*;
public class QuoteMultiServer extends Thread {

protected DatagramSocket SOCK=null;
//protected DatagramSocket SOCK2=null;
public int QuoteCount=0;
public int Time_Interval=3000;
public int Time_Interval2=5000;
InetAddress IP_ADDRESS_GROUP =InetAddress.getByName("224.0.0.0");
//InetAddress IP_CLIENT_ADDRESS=InetAddress.getByName("224.0.0.0 ");
public String[] PirateQuote={ "dcsfffffffffffffffffff",
"deeeeeeeeeew", "fhdfkhjhhhhhhhhhhhhhhhhhhhhhhh",
"fdkjkfdghgdfgdfgfdg",
"dsdjsfsdkfdfjlfklfkd;ff;;f",
"shjfjshfskjfjhfjhdfhjhdfhdsfjh",
"jhfsjhfsdjhfjsfjksfjksdfkjsdjk",
"hehfehfhsfhdsjfjfjkdjkfjfjdjdfjkjfd",
"dfsfsfsdsfsdfsdfsf"
};
public static void main(String[] args) throws Exception
{
QuoteMultiServer SERVER=new QuoteMultiServer();
SERVER.start();

}


public QuoteMultiServer() throws IOException
{
SOCK=new DatagramSocket(2000);
//SOCK2=new DatagramSocket(2000);
System.out.println("Launched Multicast Serve thread");
System.out.println("Waiting fo client connection");
}
public void run()
{
while(true)
{
try
{


byte[] BUFFER=new byte[256];
String MESSAGE=NextQuote();
BUFFER=MESSAGE.getBytes();
//InetAddress IP_ADDRESS_GROUP =InetAddress.getByName("224.0.0.0");
DatagramPacket PACKET=new DatagramPacket(BUFFER,BUFFER.length,IP_ADDRESS_GRO UP,208);
SOCK.send(PACKET);
try
{
sleep(Time_Interval);
}
catch(InterruptedException X)
{
X.printStackTrace();
}

}
catch(IOException X)
{
X.printStackTrace();
break;
}
}

SOCK.close();
}


protected String NextQuote()
{
String MESSAGE="";
Date TheTime=new Date();
if(QuoteCount >PirateQuote.length-1)
{
MESSAGE="\n fresh out quotes"+ TheTime.toString() + "";
System.out.println("\n All quotes ae served ");

}
else
{
MESSAGE=(QuoteCount + 1)+ "" + PirateQuote[QuoteCount];
System.out.println("\n Serving out Quote#" + (QuoteCount+1) + "");
QuoteCount++;
}
return MESSAGE;
}

}