Hello i have a question which is a bit about threads and a bit about sockets but im not sure which forum to put it in hope this is the right one.
I have these classes
and i have a class for an InputStream and an OutputStream
and finally my output stream
As you can see i am trying to write a client to connect to a telnet server which is a text based game, i get the initial text, but when i put my text in it doesnt reply to me, if i put in some invalid text it replies.
example = Enter your login id: If i put Andy nothing happens If i put Andy# it tells me ive entered a wrong id
Your InputStream class only reads and sends one line to the server. Since this isn't in a loop, the thread terminates immediately, leaving only the thread that's reading data from the server.
By the way, be careful when naming your classes with the same name as a common Java core class, like Input- and OutputStream. You might want to name these classes ReaderThread and WriterThread, for example.
If you go to rigidsoftware.com there is a program called chessOne which is free for download and the source is there.
It uses a telnet server to connect to freechess.org. You can look at the code and see how to handle the input stream, output streams, and get a bit of info on the threading model of client-server as well. Should be easy to understand .
the sockets is handled basically by 2 classes, IOProcessor and something else I think.