Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Java socket Server compile errors.. (http://www.programmingforums.org/showthread.php?t=3589)

n3o_X Apr 26th, 2005 5:36 PM

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);
        }
    }
}

When i compile it: javac echo3.java
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)

n3o_X Apr 26th, 2005 5:39 PM

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?

casesensitive Nov 17th, 2007 9:32 PM

Re: Java socket Server compile errors..
 
Welcome to the self-help program.

lectricpharaoh Nov 18th, 2007 12:39 AM

Re: Java socket Server compile errors..
 
Quote:

Originally Posted by casesensitive
Welcome to the self-help program.

Welcome to Thread Archaeology 101. You do realize that this thread is over two years' dead, right? Right?


All times are GMT -5. The time now is 4:27 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC