i m trying to echo data, send to server back back on client on the local system using localhost but it returns null..i am using apache tomcat 6.0 as web server.please suggest some way to do this or suggest ,if any, problem with the code?
using 8080 as port no. bcoz tomcat listens on it
code is
using 8080 as port no. bcoz tomcat listens on it
code is
Code:
try {
echoSocket = new Socket("localhost",8080);
out = new PrintWriter(echoSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host: taranis.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for "
+ "the connection to: taranis.");
System.exit(1);
}
BufferedReader stdIn = new BufferedReader(
new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null) {
out.println(userInput);
System.out.println("echo: " + in.readLine());
}
Comment