socket problem
- From: "vindhya" <manish.sing@xxxxxxxxx>
- Date: 29 Jul 2005 05:59:28 -0700
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.
.
- Follow-Ups:
- Re: socket problem
- From: Andrew Thompson
- Re: socket problem
- From: Thomas Hawtin
- Re: socket problem
- From: jan V
- Re: socket problem
- From: Andrew Thompson
- Re: socket problem
- Prev by Date: Re: integration between struts and servlet auth
- Next by Date: Re: integration between struts and servlet auth
- Previous by thread: "Memory leak" in javax.xml.xpath.XPath
- Next by thread: Re: socket problem
- Index(es):
Relevant Pages
|