![]() |
|
![]() |
|
|
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 11: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 |
|
Programmer
Join Date: Oct 2007
Posts: 41
Rep Power: 0
![]() |
Re: Java socket Server compile errors..
Welcome to the self-help program.
|
|
|
|
|
|
#4 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,197
Rep Power: 5
![]() |
Re: Java socket Server compile errors..
Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|