InetSocketAddress

package inet;

import java.net.InetSocketAddress;

public class TestInetSocketAddress {

    public static void main(String[] args) {
        InetSocketAddress inetSocketAddress1=new InetSocketAddress("127.0.0.1",8080);
        InetSocketAddress inetSocketAddress2=new InetSocketAddress("localhost",8080);

        System.out.println(inetSocketAddress1);
        System.out.println(inetSocketAddress2);

        System.out.println(inetSocketAddress1.getAddress());
        System.out.println(inetSocketAddress1.getHostName());
        System.out.println(inetSocketAddress1.getPort());

    }
}

posted @ 2021-07-13 14:29  卡卡发  阅读(110)  评论(0)    收藏  举报