网络通信 三要素

网络通信的三要元素

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

    端口号

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

协议

相关推荐
JuiceFS4 小时前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
chen94510 小时前
mysql 3节点mgr集群部署
运维·后端
LH_R11 小时前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler11 小时前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs
少妇的美梦1 天前
logstash教程
运维
chen9451 天前
k8s集群部署vector日志采集器
运维
chen9451 天前
aws ec2部署harbor,使用s3存储
运维
白帽黑客沐瑶1 天前
【网络安全就业】信息安全专业的就业前景(非常详细)零基础入门到精通,收藏这篇就够了
网络·安全·web安全·计算机·程序员·编程·网络安全就业
christine-rr1 天前
linux常用命令(4)——压缩命令
linux·服务器·redis
東雪蓮☆1 天前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs