How to catch this exception
Hi
I have created a simple client server program . In the Client i give the server ip/name and port number in command line... but when i try to run the client on a port on which the server is not running .. the following message is generated....
C:\Program Files\Java\jdk1.5.0_02\bin>java echocli darkside 1000
Exception in thread"main" java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
at java.net.Socket.connect(Socket.java:507)
at java.net.Socket.connect(Socket.java:457)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:207)
at echocli.main(echocli.java:51)
C:\Program Files\Java\jdk1.5.0_02\bin>
I have written this to catch the exception but ...the error statement is not printed.....
catch(ConnectException e1)
{
System.out.println("\n No server running on that port " );
}
whats wrong...why is it not catching this exception........

