Re: singe thread per connection



On Fri, 11 Jul 2008 12:32:19 -0700, Praki <visitprakashindia@xxxxxxxxx> wrote:

I need to implement the telnet using single thread for one telnet
connection. I saw one of the usage of this telnetd with four threads
for single connection. I need to open arround minimum of 500 telnet
connections. so it will not be good to have 500*4 threads.

For that matter, I'm not convinced it would be good to have 500 threads.

is there
any way in which i can create telnet connection with single thread for
single connection.

I'm not really clear on why the example you've see used four threads for one connection. I would think two would be enough even for the most naïve implementation. However, to get your implementation down to one thread per connection, and possibly even fewer (i.e. have a thread that handles multiple connections), you may want to look at SelectableChannel (you can get one from a Socket instance) and the Selector class (which allows you to have a single thread monitor multiple SelectableChannels for read and write readiness).

I'm not familiar enough with Java to know if there's an asynchronous API for the stream classes, but if there is, that would be another option.

Pete
.



Relevant Pages

  • Re: Best Practices - Connecting to Oracle from a fat client
    ... logic is on the client, and not on a centralized server, connection pooling ... Do not open a single connection ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Need Help with Select @@ Identity
    ... But that is a bad practise. ... CATID FROM Categories. ... How do I complete this in one connection? ... that all these steps should be performed in a single connection. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Need Help with Select @@ Identity
    ... that all these steps should be performed in a single connection. ... connection specific command. ... Dim Conn As New OleDbConnection ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: singe thread per connection
    ... for single connection. ... I need to open arround minimum of 500 telnet ... InputStream is =new BufferedInputStream); ...
    (comp.lang.java.programmer)
  • RE: Duplicate Connections
    ... I just ran a test using the following code and it created a single connection ... CategoryName"; ... > I am using the SQLConnection object to establish a connection a SQL Server ...
    (microsoft.public.dotnet.framework.adonet)