V
vindhya
I am a newbie to java and trying to compile this piece of code. But I
am getting an error on line 15...
import java.util.*;
import java.io.*;
import java.net.*;
import java.net.InetAddress;
public class Client {
public static void main (String[] args) throws IOException {
Socket mysocket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
InetAddress ip = InetAddress.getLocalHost() ;
Integer port = 9990;
mysocket = new Socket(ip,port); //LINE 15
out = new PrintWriter(mysocket.getOutputStream(),true);
in = new BufferedReader(new
InputStreamReader(mysocket.getInputStream()));
}
catch (UnknownHostException e) {
System.out.println ("Caught exception");
}
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();
mysocket.close();
}
}
Any suggestions.
Thanks in advance.
am getting an error on line 15...
import java.util.*;
import java.io.*;
import java.net.*;
import java.net.InetAddress;
public class Client {
public static void main (String[] args) throws IOException {
Socket mysocket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
InetAddress ip = InetAddress.getLocalHost() ;
Integer port = 9990;
mysocket = new Socket(ip,port); //LINE 15
out = new PrintWriter(mysocket.getOutputStream(),true);
in = new BufferedReader(new
InputStreamReader(mysocket.getInputStream()));
}
catch (UnknownHostException e) {
System.out.println ("Caught exception");
}
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();
mysocket.close();
}
}
Any suggestions.
Thanks in advance.