Java网络基础和Socket通信基础详情
一、网络基础
1、InetAddress
InetAddress构造器私有,可以通过多种方式获得inetAddress对象
InetAddress ip = InetAddress.getLocalHost();//获取本机IP
ip = InetAddress.getByName("100.64.141.89");//通过名字获取指定地址IP
String name = ip.getHostName();//通过IP获取IP名字
2、URL统一资源定位符
典型构成:1、网络协议(https://);2、主机地址(192.168.46.20/myServlet);3、端口号(80);4、资源路径(crm/index.jsp);5、查询地址(gid=117)
一、网络基础
1、InetAddress
InetAddress构造器私有,可以通过多种方式获得inetAddress对象
InetAddress ip = InetAddress.getLocalHost();//获取本机IP
ip = InetAddress.getByName("100.64.141.89");//通过名字获取指定地址IP
String name = ip.getHostName();//通过IP获取IP名字
2、URL统一资源定位符
典型构成:1、网络协议(https://);2、主机地址(192.168.46.20/myServlet);3、端口号(80);4、资源路径(crm/index.jsp);5、查询地址(gid=117)