socket problem



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.

.



Relevant Pages

  • Re: socket problem
    ... > I am a newbie to java and trying to compile this piece of code. ... Prev by Date: ...
    (comp.lang.java.programmer)
  • Re: socket problem
    ... > I am a newbie to java and trying to compile this piece of code. ... Prev by Date: ...
    (comp.lang.java.programmer)
  • error cannot resolve symbol in jdk1.3
    ... I am newbie to java programming.I have have two classes named ... ReadFile.java it is fine no problem But when i compile ReadWriteFile I ... download jdk1.0,,jdk1.1and importantly jdk1.2 softwares I have searched ...
    (comp.lang.java.programmer)
  • Re: socket problem
    ... >> vindhya wrote: ... >>> I am a newbie to java and trying to compile this piece of code. ...
    (comp.lang.java.programmer)
  • Re: simple compilaton question
    ... > before I try to compile Main? ... "javac *.java" in each of my java source file directories the first ... with gcj. ... slow to ask for help on mailing lists. ...
    (comp.lang.java.programmer)