网络通信 三要素

网络通信的三要元素

  1. IP地址

  2. 端口号

  3. 协议

  4. java 复制代码
    package InetAddressTest;
    
    import java.net.InetAddress;
    
    public class InetAddress1 {
        public static void main(String[] args)throws Exception {
           // InetAddress的使用
    
    
            //1:获取本机IP地址对象
           InetAddress ip1= InetAddress.getLocalHost();
            System.out.println(ip1.getHostName());
            System.out.println(ip1.getHostAddress());
    
            //2:获取指定的IP地址 或者域名的IP地址
           InetAddress ip2= InetAddress.getByName("www.baidu.com");
          // InetAddress ip2= InetAddress.getByName("www.baidu.com");
            System.out.println(ip2.getHostName());
            System.out.println(ip2.getHostAddress());
    
            //ping IP ==  www.baidu.com
            System.out.println(ip2.isReachable(6000));
    
    
        }
    }

    端口号

我们自己开发的程序用注册端口

协议

相关推荐
zhurui_xiaozhuzaizai几秒前
MoE模型的核心架构---专家网络---门控网络/路由器
网络·架构
GoWjw2 分钟前
内存管理【3】
linux·服务器·c++·ubuntu
i橡皮擦8 分钟前
使用gamedig 查询恐龙岛TheIsle游戏服务器
运维·服务器·游戏·steam·恐龙岛·the isle
pcc_is_world18 分钟前
Nginx HTTPS服务器搭建与认证配置
服务器·nginx·https
White-Legend23 分钟前
支持docker一键部署了
运维·docker·容器
shizhan_cloud36 分钟前
Shell 变量进阶知识
linux·运维
火山灿火山41 分钟前
Qt常用控件(一)
服务器·qt
普罗米修斯Aaron_Swartz1 小时前
云主机(容器)内实现本地VNC访问
网络·docker
企鹅侠客2 小时前
Ubuntu本地部署AnythingLLM实现本地文档RAG
linux·运维·ubuntu·llm
醇氧2 小时前
Git 合并冲突提示 Local Changes Prevent from Merge
运维·git