Connecting a Socket to echo port
Hi,
I am trying to connect to the echo port of my own system. The code I am using is provided here under. When I am executing this I am getting an IOException.
I am running this on Windows XP machine...
I belive this code is working fine when I exectuted on a windows 98 machine..
Pls. suggest if I am doing anything wrong.
Thanks & Regards
G.Vasu
_
******************************************************************************
-
import java.io.*;
import java.net.*;
public class EchoClient {
public static void main(String[] args) throws IOException {
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
echoSocket = new Socket("127.0.0.1", 7);
out = new PrintWriter(echoSocket.getOutputStream(), true);in = new BufferedReader(new InputStreamReader(
echoSocket.getInputStream()));
} catch (UnknownHostException e) {
System.err.println("Don't know about host you are connecting.");
System.exit(1);
} catch (IOException e) {
System.err.println("Couldn't get I/O for "
+ "the connection to the target systema.");
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());
}
out.close();
in.close();
stdIn.close();
echoSocket.close();
}
}
Message was edited by:
G.Vasu

