Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Help wanted on Client-Server

I'm in the early stages of writing a client-server program. I've got the client and the server communicating (I think). I send text from the client to the server. I then want the server side BufferedReader
in

to be read into a variable. I've tried doing it using
String inputLine = in.readLine()

but it keeps throwing an IOException. I can't work out why.

try {
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
System.out.println("The printwriter and bufferedreader have been set up.");
String inputLine, outputLine;
inputLine = in.readLine();
System.out.println(inputLine);
} catch (IOException e) {
System.out.println(e);
}

The serverSocket and socket have been set up properly as far as I can tell. It's just the above portion of code that seems to be causing a problem. My knowledge of Java is fairly basic at the moment, so any help would be greatly appreciated.
[1185 byte] By [SE-Student] at [2007-11-11 8:09:42]
# 1 Re: Help wanted on Client-Server
Can you tell us what the error message is please.
major at 2007-11-11 22:36:22 >
# 2 Re: Help wanted on Client-Server
The following link may help

http://williams.comp.ncat.edu/Networks/JavaSocketExample.htm
arul at 2007-11-11 22:37:22 >