Carey Brown wrote:You'll need to create a socket connection, and then using that to create two threads, one for getting user input and writing it to the socket, and the other to read from the socket and write the output to the console.
Without threads, as you have done, your calls to readLine() block each other.
Carey Brown wrote:This will never be true because readLine() strips off the new-line character(s).
Chhris Jjohnston wrote:
Carey Brown wrote:You'll need to create a socket connection, and then using that to create two threads, one for getting user input and writing it to the socket, and the other to read from the socket and write the output to the console.
Without threads, as you have done, your calls to readLine() block each other.
Aren't inFromUser and inFromServer two separate threads?
Chhris Jjohnston wrote:
Carey Brown wrote:This will never be true because readLine() strips off the new-line character(s).
Do you know a way to have this run until theres a blank line? (e.g. pressing enter without typing anything)
Chhris Jjohnston wrote:Need to send a proper HTTP header to any server and receive a request but not allowed to use and of the built in java classes....
Damon McNeill wrote:
Chhris Jjohnston wrote:Need to send a proper HTTP header to any server and receive a request but not allowed to use and of the built in java classes....
I wonder why? Is it just some arbitrary assignment? There's libraries that will do this and more, already developed. No need to reinvent the wheel.
GET / HTTP/1.0
Host: google.com
Connection: close
Header: Value
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Don't get me started about those stupid light bulbs. |