Code example for ServerSocket

Methods: close, getInetAddress

0
    /** 
     * @tests java.net.ServerSocket#getInetAddress() 
     */ 
    public void test_getInetAddress() throws IOException { 
        InetAddress addr = InetAddress.getLocalHost();
        s = new ServerSocket(0, 10, addr);
        try { 
            assertEquals("Returned incorrect InetAdrees", addr, s
                    .getInetAddress());
        } finally { 
            s.close();
        } 
    } 
 
    /** 
     * @tests java.net.ServerSocket#getLocalPort() 
     */ 
    public void test_getLocalPort() throws IOException { 
        // Try a specific port number, but don't complain if we don't get it 
        int portNumber = 63024; // I made this up
        try {