CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2007
    Posts
    249

    Question 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

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    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
  •  





Click Here to Expand Forum to Full Width

Featured