On Mon, Nov 24, 2008 at 11:22 PM, <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to connect to a server using Socket, but the server is not
> running - shouldn't an exception be generated? I have:
>
> Socket s = null;
> try {
> s = new Socket();
> s.setSoTimeout(1000);
> s.connect(new SocketAddress("xxx.yyy.zzz.www",6000),10000);
> }
> catch (Exception e)
> {
> System.err.println(e);
> e.printStackTrace();
> }
>
> catch statements does not get entered. Furthermore, a call to:
>
> s.isConnected()
>
> returns TRUE. Once I try using the socket, I get some null pointer
> exceptions etc, I know the server application is NOT running, so how do
> you check if you really connected or not?
>
> I am using java available on FC4...
>
> Thanks
> Dhiraj.
>
>
Dhiraj,
I wonder how you are able to instantiate SocketAddress, isn't it abstract?
Assuming you used InetSocketAddress, here is what I get
java.net.UnknownHostException: xxx.yyy.zzz.www
java.net.UnknownHostException: xxx.yyy.zzz.www
at
java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:158)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:381)
at java.net.Socket.connect(Socket.java:537)
at Test.main(Test.java:10)
and line 10 is
s.connect(new InetSocketAddress("xxx.yyy.zzz.www",6000),10000);
--
Satish Vellanki
[Non-text portions of this message have been removed]