<commit_before>package com.qiniu.android.dns;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * Created by bailong on 15/7/3.
 */
public final class Network {
    private static String previousIp = "";

    //    use udp socket connect, tcp socket would connect when new.
    public static String getIp() {
        DatagramSocket socket = null;
        try {
            socket = new DatagramSocket();
            InetAddress addr = InetAddress.getByName("172.16.17.32");
            socket.connect(addr, 53);
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }

        InetAddress local = socket.getLocalAddress();
        return local.getHostAddress();
    }


    public static synchronized boolean isNetworkChanged() {
        String nowIp = getIp();
        if (nowIp.equals(previousIp)) {
            return false;
        }
        previousIp = nowIp;
        return true;
    }
}<commit_msg>socket close<commit_after>package com.qiniu.android.dns;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * Created by bailong on 15/7/3.
 */
public final class Network {
    private static String previousIp = "";

    //    use udp socket connect, tcp socket would connect when new.
    public static String getIp() {
        DatagramSocket socket = null;
        try {
            socket = new DatagramSocket();
            InetAddress addr = InetAddress.getByName("172.16.17.32");
            socket.connect(addr, 53);
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }

        InetAddress local = socket.getLocalAddress();
        socket.close();
        return local.getHostAddress();
    }


    public static synchronized boolean isNetworkChanged() {
        String nowIp = getIp();
        if (nowIp.equals(previousIp)) {
            return false;
        }
        previousIp = nowIp;
        return true;
    }
}
{'fraction_non_alphanumeric': 0.1022332506203474, 'fraction_numerical': 0.01488833746898263, 'mean_word_length': 2.111111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1560405', 'n_tokens_mistral': 570, 'n_tokens_neox': 544, 'n_words': 148}