Code example for Socket

Methods: closeconnectgetLocalAddress

0
     * private space; otherwise, no IGD mappings are necessary. 
     * 
     * @throws IOException 
     */ 
    private static InetAddress determineDefaultRouteLocalAddress() throws IOException {
        Socket socket = new Socket();
        try { 
            socket.connect(new InetSocketAddress("www.google.com", 80));
            return socket.getLocalAddress();
        } finally { 
            socket.close();
        } 
    } 
 
    private synchronized InetAddress getDefaultRouteLocalAddress() throws IOException {
        if (mLocalAddress == null) {
            mLocalAddress = determineDefaultRouteLocalAddress();
        } 
 
        return mLocalAddress;
Contextual code suggestions in your IDE  Get Codota for Java