Could it be that 'available()' returns 0 a bit quicker in your new
setup?
Maybe you can try setting a timeout on the client socket:
clientSocket.setSoTimeout(getClientSocketTimeout_ms());
then read until you get an EOL or a timeout, like so:
public static String readLine(Reader isr, int maxLength) throws IOException {
StringBuffer buf = new StringBuffer();
boolean stop = false;
while (buf.length() < maxLength && !stop) {
int ch = isr.read();
if (ch < 0 || ch == '\n' || ch == '\r') {
stop = true;
} else {
buf.append((char) ch);
}
}
return buf.toString();
}
--On Monday, August 16, 2004 4:06 PM -0300 Diogo Saad <diogo@ibnetwork.com.br> wrote:
> Hi,
>
> I made a classe called TelnetService that uses TelnetClient.
> One of the methods of this class is read() it's supposed to read all
> available data from telnet inputstream and return it.
> I've been using this method for some time in my machine (win2k server)
> with no problems.
> Now I tryed to use it into a linux machine and I got some problems!!
> When I try to read() all available data from telnet inputstream it
> returns a splited string ( not with all the content)...
> Feels like it's an assyncronous client, because if I debug the system,
> add a breakpoint and wait for some time, it reads the whole content.
> But if i run my app without debug it does not return it completly...
> feels like i'm trying to read the content before the server sends the
> full response!
> The source for read() is bellow
> Can you help me?
>
>
> public String read() {
> StringBuffer sb = new StringBuffer();
> try {
> char ch = (char) telnetInput.read();
> while (telnetInput.available() > 0) {
> sb.append(ch);
> ch = (char) telnetInput.read();
> }
> log.debug(sb.toString());
> return sb.toString();
> } catch (Exception e) {
> log.error(e);
> }
> return null;
> }
>
>
> Diogo Saad
> diogo@ibnetwork.com.br
> Inter Business Tecnologia e Servicos
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
-- David Tonhofer
M-PLIFY S.A.
Resp. Informatique
47, av. de la Liberté
L-1931 Luxembourg
Tel: +352 261846-52
Fax: +352 261846-46
Mob: +352 021-139031
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
|