Thanks,with your help,I has resolved that question.I close the
serversocket in destroy() method and it works well.

  Howerver I meet with another question.I want to know if the serversocket
is my hope beacause the applet can't talk with servlet
well.Then after create the serversocket on port 10000,I use
serversocket.getLocalPort() to see the real value,but it return 0.I
don't know why i get this value.

Thanks advanced.
Huyong


> >
> > The following is the code:
> >
> > public class UsersServlet extends HttpServlet implements Runnable{
> >
> >   static int SERVLET_PORT=10000;
> >
> >   ServerSocket  serverSocket;
> >
> >   RandomAccessFile myfile;
> >
> >   Thread mythread=new Thread(this);
> >
> >   public void run(){
> >     try{
> >         serverSocket = new ServerSocket(SERVLET_PORT);
> >         myfile=new RandomAccessFile("c:\\temp\\servlet.txt","rw");
            myfile.write(serverSocket.getLocalPort());
            myfile.close();
> >         while (true)
> >            handleClient(serverSocket.accept());
> >          }catch(IOException e){}
> >
> >
> >   }
> >
> >   public void init(ServletConfig config) throws ServletException {
> >         super.init(config);
> >         mythread.start();
> >
> >   }
> >
> > public void handleClient(Socket client){
> >     new UserConnection(this, client).start();
> >
> > Any suggetion is helpful to me.
> >
> > Regards
> > Huyong
> >
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to