IP 定位计算机
lnetAddress
端口 定位软件
1.区分软件
2.两个字节 0-65535 TCP UDP
3.同一个协议端口不能冲突
4.端口号越大越好
了解部分公认端口 80 HTTP协议 443 HTTPS 协议 8080 Tomcat服务器 1521Oracle 3306 MYSQL
lnetScokerAddress
1.构造器
new lnetScokerAddress(域名|地址,端口)
2.方法
getAddress()//获取地址
getport()//获取端口
URL 定位软件里的每一份资源
URL :统一资源定位符(Universal Resource Locator),互联网三大基石之一(html,http)
https://www.baidu.com:443/index.html?uname=shsxt&age=18#a
1.协议: https
2.域名,计算机: www.baidu.com
3.端口(默认80):443
4.请求资源 index.html?uname=shsxt&age=18
参数:uname=shsxt&age=18
锚点:a
package 网络编程开篇;
import java.net.MalformedURLException;
import java.net.URL;
public class urltest {
public static void main(String[] args) throws MalformedURLException {
URL url =new URL("https://www.baidu.com:443/index.html?uname=shsxt&age=18#a");
System.out.println("协议"+url.getProtocol());
System.out.println("域名ip"+url.getHost());
System.out.println("端口"+url.getPort());
System.out.println("请求资源"+url.getPath());
System.out.println("请求资源"+url.getFile());
System.out.println("参数"+url.getQuery());
System.out.println("锚点"+url.getRef());
}
}