分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

Intenet 地址

发布时间:2023-09-06 02:34责任编辑:沈小雨关键词:暂无标签

java.net.InetAddress类是java对Ip地址(包括ipv4和ipv6)的高层表示,大多数其他网络类都要用到这个类,包括Socket, ServerSocket, URL, DatagramSocket, DatagramPacket等

InetAddress address = InetAddress.getByName("www.baidu.com"); //生产InetAddress的工厂方法,设置InetAdress类中的一个私有字段,并建立与本地DNS服务器的一个链接,来查找数组和名字地址 , 不检查DNS

InetAddress[] address = InetAddress.getAllByName("www.baidu.com");//得到所有地址

InetAddress address = InetAddress.getLocalHost(); //得到主机地址,即运行这段代码的主机地址 ,不可信代码总是返回主机名127.0.0.1

Ipublic static InetAddress.getByAddress(byte[] addr) throws UnknownHostException //用一个IP地址创建一个InetAddress对象

Ipublic static InetAddress.getByAddress(String hostname,byte[] addr) throws UnknownHostException //用一个主机名和一个IP地址创建一个InetAddress对象

byte[] address = {107,23,(byte)216,(byte)196} ?//必须把两个大数组转换成字节InetAddress lessWrong= InetAddress.getByAddress(address) ?;

SecurityManager s = new SecurityManager();
s.checkConnect("223.210.232.29", 80);如果调用线程不允许打开与指定的主机和端口号的套接字连接,则抛出一个 SecurityException

Intenet 地址

原文地址:https://www.cnblogs.com/jiangfeilong/p/10508051.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved