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........

[1477 byte] By [Joe_n00ba] at [2007-10-2 2:04:17]
# 1
Is line 51 (echocli.java:51) wihtin the try block?
MartinHilperta at 2007-7-15 19:45:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
thanks dude..appreciated
Joe_n00ba at 2007-7-15 19:45:40 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...