Ping地址

—— 平安地址

欢马劈雪     最近更新时间:2020-01-02 10:19:05

557
平安地址


//package com.nowjava;

import java.io.IOException;
/**
 * n o w j a   v  a . c o m - 时  代  Java 提 供 
**/

import java.net.InetSocketAddress;

import java.net.Socket;


public class Main {

    @SuppressWarnings("resource")

    public static boolean ping(String address, int port) {

        InetSocketAddress isa = new InetSocketAddress(address, port);

        Socket connection = new Socket();

        try {

            connection.connect(isa, 5 * 1000);

        } catch (IOException e) {

            
展开阅读全文