Why don't ppl use threads for serversockets? They place them in main and any
such places. Are there any drawbacks to this?
listenSocket = new ServerSocket(port);
Socket clientSocket = listenSocket.accept();
Re: ServerSocket question
I'm not an expert on the subject, but since no one else posted a response
give it a shot. In one of my CS classes we wrote a proxy server and proxy
thread. In the main we
had something like,
serverSocket = new ServerSocket(port_number);
and waited for a client to connect to the port. Then When a client connected
clientSocket = serverSocket.accept();
This started a thread that handled the real work of the proxy.
This means the server can immediately go back to it's job of waiting for
a client to connect to it's port. To answer your question about draw backs,
imagine it is really a question of what you are trying to accomplish and
the best way to
implement that in code. And not so much if it is better to do that in a thread
or in the main.
Hope this helped.
"Freddy" <.@.> wrote:
>Why don't ppl use threads for serversockets? They place them in main and
>such places. Are there any drawbacks to this?
>listenSocket = new ServerSocket(port);
>Socket clientSocket = listenSocket.accept();
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL