Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2005, 5:36 PM   #1
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
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)

Last edited by DaWei; Nov 17th, 2007 at 10:05 PM. Reason: Added code tags.
n3o_X is offline   Reply With Quote
Old Apr 26th, 2005, 5:39 PM   #2
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
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?
n3o_X is offline   Reply With Quote
Old Nov 17th, 2007, 9:32 PM   #3
casesensitive
Newbie
 
Join Date: Oct 2007
Posts: 27
Rep Power: 0 casesensitive is on a distinguished road
Re: Java socket Server compile errors..

Welcome to the self-help program.
casesensitive is offline   Reply With Quote
Old Nov 18th, 2007, 12:39 AM   #4
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4 lectricpharaoh will become famous soon enough
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?
__________________
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
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:39 PM.

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