-
February 15th, 2016, 01:57 AM
#1
SocketImpl connect is not throwing exception
Hi,
I am very new to java I am trying to execute one piece of code which should fail and throw exception. But it is not trowing any exception.
please correct me if i am wrong.
Code:
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ConcreteSocketImplTestInetAdress {
public static void main(String[] args) throws Exception {
// Get Local address
InetAddress localHost = InetAddress.getLocalHost();
ConcreteSocketImpl concreteSocket = new ConcreteSocketImpl();
try
{
concreteSocket.connect("localH11ost", 1118111); //This ip and port are wrong so i should get the exception but I am getting the output as Connected.
}
//Host not found
catch (UnknownHostException e)
{
//System.err.println(\"Don't know about host : \" + localHost);
System.exit(1);
}
catch (IOException e)
{
System.out.println("Exception");
}
System.out.println("Connected");
}
}
Output--->
Connected
-
February 15th, 2016, 09:20 AM
#2
Re: SocketImpl connect is not throwing exception
The definition of the ConcreteSocketImpl class is missing.
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|