[ajug-members] Java going bonkers
Christopher Fowler
cfowler at outpostsentinel.com
Thu Apr 28 21:16:38 EDT 2005
I'm a little confused as to when non-blocking mode is beneficial for
reading file descriptors. In UNIX and others I rarely place a socket in
non-blocking mode. I simply use a select() so that I know which file
descriptor can be read and then I go read that descriptor.
If I have cleaning up stuff to do every N minutes I use the timeout
feature in the select() so that if after N seconds no descriptor is
readable I can get out of the select and go do other things. When I'm
finished I jump back into that select.
I have processes that handle 100s of descriptors in a single thread like
this. Is this not possible in Java?
On Wed, 2005-04-27 at 14:48, Patrick Carroll wrote:
> Take a look here:
>
> http://www-106.ibm.com/developerworks/library/j-nioserver/
>
> -----Original Message-----
> From: Christopher Fowler <cfowler at outpostsentinel.com>
> Sent: Apr 27, 2005 1:21 PM
> To: Ajug List <ajug-members at ajug.org>
> Subject: [ajug-members] Java going bonkers
>
> I've got this code snippet
>
> _newClientChannel.configureBlocking( true ) ;
> writer.writeLine( "220 SAM ENS Console Proxy" ) ;
>
>
>
>
> if( response.startsWith( "myid " ) )
>
> If I telnet to the proxy server and after my telnet client sees the 220
> above I do a kill -9 on the client the server will loop forever on
> read()
>
> strace shows this as fast as possible:
>
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
> [pid 2222] read(13, "", 120) = 0
>
> Obviously this is happening inside of
>
> String response = reader.readLine( ) ;
>
> How do you protect against it?
>
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members at ajug.org
> http://www.ajug.org/mailman/listinfo/ajug-members
More information about the ajug-members
mailing list