02-Inet套接字地址

 public static void main(String[] args) {
        InetSocketAddress localhost = new InetSocketAddress("localhost", 8080);
        System.out.println(localhost.getAddress());//获取地址
        System.out.println(localhost.getHostName());//获取主机名
        System.out.println(localhost.getHostString());//获取主机字符串
        System.out.println(localhost.getPort());//获取端口
    }

localhost/127.0.0.1
localhost
localhost
8080

posted @ 2020-12-26 10:06  Java小白的搬砖路  阅读(125)  评论(0编辑  收藏  举报