![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 29
Rep Power: 0
![]() |
Java socket Server compile errors..
I'm trying to make a socket server froma tutorial I found on the net. here is the code:
import java.io.*;
import java.net.*;
public class echo3 {
public static void main(String args[]) {
// declaration section:
// declare a server socket and a client socket for the server
// declare an input and an output stream
ServerSocket echoServer = null;
String line;
DataInputStream is;
PrintStream os;
Socket clientSocket = null;
// Try to open a server socket on port 9999
// Note that we can't choose a port less than 1023 if we are not
// privileged users (root)
try {
echoServer = new ServerSocket(9999);
}
catch (IOException e) {
System.out.println(e);
}
// Create a socket object from the ServerSocket to listen and accept
// connections.
// Open input and output streams
try {
clientSocket = echoServer.accept();
is = new DataInputStream(clientSocket.getInputStream());
os = new PrintStream(clientSocket.getOutputStream());
// As long as we receive data, echo that data back to the client.
while (true) {
line = is.readLine();
os.println(line);
}
}
catch (IOException e) {
System.out.println(e);
}
}
}it gives me this error: Note: echo3.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details. after i run with deprecation it says: echo3.java:40: warning: readLine() in java.io.DataInputStream has been deprecate (line = is.readLine() ![]() Any idea on how I can fix this? (This is on a freebsd system incase that matters) Last edited by DaWei; Nov 17th, 2007 at 10:05 PM. Reason: Added code tags. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jan 2005
Posts: 29
Rep Power: 0
![]() |
AHh ... i was running it wrong... I was running it as: java echo3.class. I did it as java echo3 and it is running. Since this is a tutorial I am getting this from, what would be the best way to connect to the socket server at this point? Is there anyway to doit from telnet?
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2007
Posts: 27
Rep Power: 0
![]() |
Re: Java socket Server compile errors..
Welcome to the self-help program.
|
|
|
|
|
|
#4 | |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4
![]() |
Re: Java socket Server compile errors..
Quote:
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|