Hi, every one
I am new to java programming:
I need an expert advice. It's urgent. Please help.

I need to create a Server socket from an applet. This socket should be able to listen to client request and send back the response. I also need a client applet which will communicate with the above server.

I tried to do this in the init method of an applet class. But it doesn't work.The code is as follows. Please help:
Java Code:
import java.awt.Graphics;
import java.awt.Color;
import java.applet.Applet;
import java.io.*;
import java.net.*;

public class HelloWorld extends Applet {

    StringBuffer buffer;
    ServerSocket server;
    Socket client;
    BufferedReader in;
    PrintWriter out;
    String line;

    @Override
    public void init()
    {
        this.setBackground(Color.WHITE);
        buffer = new StringBuffer();
        buffer.append("Hello World!");

        //Create a server and show the messge that server has been started
        try
        {
            server = new ServerSocket(4321);
            buffer.append("\n");
            buffer.append("Server is ready to listen.");
        } 
        catch (IOException e)
        {
            buffer.append("Could not listen on port 4321");
            //System.exit(-1);
        }

        try
        {
            client = server.accept();
        }
        catch (IOException e)
        {
            buffer.append("Accept failed: 4321");
            //System.exit(-1);
        }

        try
        {
            in = new BufferedReader(new InputStreamReader(
                    client.getInputStream()));
            out = new PrintWriter(client.getOutputStream(),
                    true);
        }
        catch (IOException e)
        {
            //System.out.println("Read failed");
            buffer.append("Read failed");
           //System.exit(-1);
        }

        while(true)
        {
          try
          {
            line = in.readLine();
            //Send data back to client
            out.println(line);
          }
          catch (IOException e)
          {
            //System.out.println("Read failed");
              buffer.append("Read failed");
            //System.exit(-1);
          }
        }


    }

    @Override
    public void start()
    {
    }

    @Override
    public void stop() {
    }

    @Override
    public void destroy() {
        try {
            server.close();
        } catch (IOException e) {
        }

    }

    @Override
    public void paint(Graphics g) {
        g.drawRect(0, 0,
                getSize().width - 1,
                getSize().height - 1);
        g.drawString(buffer.toString(), 5, 15);
    }

    @Override
    public void update(Graphics g) {
    }
}
Am i doing the right thing. Or is there any other way.
Please help