Socket to localhost

I try to connect to a port on my local NT workstation with this code :

    import java.net.Socket;
    ...
    private Socket s ;
    ...
    try {
            s = new Socket( "localhost" , 6666 );
        }
        catch  (IOExceptions e){
            System.out.println( e.getMessage());
            e.printStackTrace();
        }

It always ends like this :
Connection refused
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:282)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:124)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:111)
    at java.net.Socket.<init>(Socket.java:221)
    at java.net.Socket.<init>(Socket.java:89)
    at ClientSocket.<init>(ClientSocket.java:34)
    at AWTAppletEditor.GetAppletParams(AWTAppletEditor.java:281)
    at AWTAppletEditor.init(AWTAppletEditor.java:160)
    at sun.applet.AppletPanel.run(AppletPanel.java:281)
    at java.lang.Thread.run(Thread.java:466)

Do I have some special service to configure on my workstation or what's wrong ?
Eric98Asked:
Who is Participating?
 
rainmalConnect With a Mentor Commented:
Well check to see that there is a server socket listening on 6666.
This error generally occurs if the socket cannot bind to the specified port.In other words check the server.
0
 
rainmalCommented:
try using "127.0.0.1" instead of  localhost...but I don't think there should be any problem there.
0
 
rainmalCommented:
To see is you have the server up try running a telnet on

hostname : 127.0.0.1
port          : 6666

0
 
Eric98Author Commented:
You are right, the port listener wasn't launched on my local workstation
0
All Courses

From novice to tech pro — start learning today.