![]() |
|
|
|
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. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|