Network programming begins ip port URL

IP targeting computer

Here Insert Picture Description
lnetAddress
Here Insert Picture Description

Port Positioning Software

1. distinguish software
2. two bytes of the TCP the UDP 0-65535
3. does not conflict with a protocol port
4. The port number the better
understand the recognized port portion 80 HTTP protocol 8080 Tomcat server 443 HTTPS protocol 1521Oracle 3306 MYSQL

Here Insert Picture Description
lnetScokerAddress

1. Constructor

new  lnetScokerAddress(域名|地址,端口)

2. Methods

getAddress()//获取地址
getport()//获取端口

URL positioning software in every resource

URL: Uniform Resource Locator (Universal Resource Locator), one of the three cornerstones of the Internet (HTML, HTTP)
https://www.baidu.com:443/index.html?uname=shsxt&age=18#a

1. Protocol: HTTPS
2. domain, the computer: www.baidu.com
3. port (default 80): 443
4. requested resource index.html uname = shsxt & age = 18 ?
Parameters: uname = shsxt & age = 18
anchors: 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());
}
}

Here Insert Picture Description
Here Insert Picture Description

Published 27 original articles · won praise 5 · Views 636

Guess you like

Origin blog.csdn.net/qq_44620773/article/details/104178792