Telnet: connect O.K., reading blocks forever
I enhanced my Socket Client class that originally only supported to connect to my own Socket Server class exchanging serialized objects to also support plain text instead of objects to connect to an (external, 3rd party) telnet server. So I introduced a Reader/Writer in addition to a ObjectInputStream/ObjectOutputStream:
switch (mode){
case OBJECT :
oos =new ObjectOutputStream(mySocket.getOutputStream());//first the OutputStream
ois =new ObjectInputStream(mySocket.getInputStream());//... THEN the InputStream (otherwise blocks)
break;
case TEXT :
br =new BufferedReader(new InputStreamReader(mySocket.getInputStream()));//... THEN the InputStream (otherwise blocks)
bw =new BufferedWriter(new OutputStreamWriter(mySocket.getOutputStream()));//first the OutputStream
break;
}
in my run() method I process the server response:
Serializable o =null;
switch (mode){
case TEXT :
while (!br.ready()){//never ready after connect
Utils.sleep(100);
}
o = br.readLine();//blocks forever after connect
break;
case OBJECT :
default :
o = (Serializable) ois.readObject();//wait to get next message from server
break;
}//switch (mode)
This works for OBJECT mode and it works during connecting to the telnet server in TEXT mode, i.e. I also receive the welcome messages from the telnet server. But when I send a message (string) to the server, I don't get any response back. The code blocks forever atbr.readLine() and for testing alsobr.ready() is always false.
Is this a specification to the telnet protocol? Do I have to send some control characters?

