其他分享
首页 > 其他分享> > 端口Port

端口Port

作者:互联网

端口

端口表示计算机上的一个程序的进程;

package com.wang.netStudy;

import java.net.InetSocketAddress;

public class TestInetSocketAddress {
    public static void main(String[] args) {
        InetSocketAddress socketAddress = new InetSocketAddress("127.0.0.1", 8080);
        InetSocketAddress socketAddress2 = new InetSocketAddress("localhost", 8080);
        System.out.println(socketAddress);
        System.out.println(socketAddress2);

        System.out.println(socketAddress.getAddress());
        System.out.println(socketAddress.getHostName());//地址
        System.out.println(socketAddress.getPort());//端口
    }
}

标签:端口,System,socketAddress,println,Port,InetSocketAddress,out
来源: https://www.cnblogs.com/wshjyyysys/p/15860225.html