File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java.io Read blocking

 
terry Kiernan
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am experiencing a problem with blocking on read using the the following stream.

I don't want to use available() as this is conlicting with the ssl client

Can some one suggest how I can solve this where by the read won't block .

Any suggestions much appreciated .

private TelnetClient client;
private BufferedInputStream is;
is = new BufferedInputStream(client.getInputStream());
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[I assume you are using Apache commons TelnetClient]

You can only have a non blocking read if the stream you get can give you a SelectableChannel which the class you are using does not seem to provide.
That was a point to point answer to your question
However, if you tell us more about your problem i.e. why is it that you do not want to block the read or in which situation you do not want to block a read. We will be able to give you some alternatives, if possible.
 
terry Kiernan
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I am using the org.apache.commons.net.telnet.TelnetClient however i need to use BufferedInputStream from java.io

Why i can't use the available() is because when I try to do a connection over ssl it falls over.

I want the option to use a telnet hand shake or a ssl hand shake

but when I call the available() method as i read back from the stream when using the ssl handshake (SSLSocket) it won't connect however when I use the telnet all is fine and of course the read doesn't BLOCK.

Thats why i can't use the available method as it breaks the SSLSocket connection. so was hoping if i could use read that won't block or some other way to get around this issue....

I switched on debug on the SSL connection
System.setProperty( "javax.net.debug", "ssl");

and i got this in my output when i was calling the java.io.available() method
EOF received that violates SSL protocol

[ December 11, 2008: Message edited by: terry Kiernan ]
[ December 12, 2008: Message edited by: terry Kiernan ]
 
Peter Lawrey
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very few packages support SSL and non-blocking IO.
It is worth nothing that non-blocking IO adds some complexity to your code.
You may be better of with using blocking IO.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic