Re: Bad ServerSocket ! Listen! Listen! Listen!
From: kjc (ksitron_at_elp.rr.com)
Date: 08/01/04
- Next message: sks: "Re: java.Contains(String search) method to be made in Java API ?"
- Previous message: John B. Matthews: "Re: StringTokenizer"
- In reply to: Donny: "Bad ServerSocket ! Listen! Listen! Listen!"
- Next in thread: Steve Horsley: "Re: Bad ServerSocket ! Listen! Listen! Listen!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 01 Aug 2004 17:01:30 GMT
#1, the ServerSocket doesn't start a new thread, you do.
#2, The code is blocking because a) you don't have the thread properly
coded, and b) in your thread, your're waiting for I/O
Donny wrote:
> ok .. just wanted some help .. ( throw new YeahWeKnowException() !!)
>
> after extensive 're-search' , i've found out that a ServerSocket is
> supposed to go back to listening after starting a new Thread to handle
> the returned Socket...
>
> here's the problem-code:
>
> ServerSocket serv_sock = new ServerSocket(80);
> while(true) {
> Socket temp = serv_sock.accept();
> new ServiceManager(temp).start(); //code is blocking here!!
> }
>
>
> ServiceManager is a class that extends Thread.
> what is happening is that code blocks at the area shown... the while
> loop is not continued, until the socket that is passed to the
> ServiceManager is closed...
> the serv_sock doesn't go back to listening...
>
> ... could anyone please throw some light on the matter..??
>
> thanks in advance....
- Next message: sks: "Re: java.Contains(String search) method to be made in Java API ?"
- Previous message: John B. Matthews: "Re: StringTokenizer"
- In reply to: Donny: "Bad ServerSocket ! Listen! Listen! Listen!"
- Next in thread: Steve Horsley: "Re: Bad ServerSocket ! Listen! Listen! Listen!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|