网络通信 三要素

网络通信的三要元素

  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));
    
    
        }
    }

    端口号

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

协议

相关推荐
2601_949221032 小时前
Splashtop赋能企业级远程办公全场景安全连接成选型优选
运维·人工智能·安全
七度黑光2 小时前
用 openclaw 给故障复盘打分:质量审核自动化实践
运维·服务器·前端·数据库·自动化
xuefeiniao2 小时前
docker.desktop无法启动,导出镜像后
服务器·docker
123过去2 小时前
nfc-list使用教程
linux·网络·测试工具·安全
last demo3 小时前
mysql
运维·数据库·mysql·oracle
攻城狮在此3 小时前
华三交换机链路聚合配置(三层聚合)
网络·华为
灰阳阳3 小时前
Dockerfile实践-构建Nginx镜像
运维·nginx·docker·dockerfile
evo-master4 小时前
网络故障排除方法
linux·服务器·网络
Johnstons4 小时前
网络流量监控工具怎么选
运维·网络·网络故障排除·网络流量分析·网络性能监控
爱学习的小囧5 小时前
VMware Horizon 8 智能卡认证信任库配置攻略:新增 Root CA 导入指南
服务器·esxi·vmware·horizon