网络编程,概述,网络通信要素,ip地址,端口Port
2021/8/26 1:06:09
本文主要是介绍网络编程,概述,网络通信要素,ip地址,端口Port,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
网络编程
1.1概述
信件
计算机网络:
计算机网络是指将地理位置不同的具有独立功能的多台计算机计算机/140338)及其外部设备,通过通信线路连接起来,在网络操作系统网络操作系统/3997),网络管理软件及网络通信协议的管理和协调下,实现资源共享和信息传递的计算机系统。
网络编程的目的:
无线电台...传播交流信息,数据交换,通信
想要达到这个效果需要什么:
1.如何精准的定位网络上的一台计算机 端口,定位到这个计算机上的某个资源
2.找到了这个主机,如何传输数据?
Javaweb:网页编程 B/S
网络编程 :TCP/IP C/S
1.2 网络通信的要素
如何实现网络的通信?
1.通信双方的地址:
ip
端口
2.规则:
TCP/IP参考模型:
小结:
1.网络编程中有两个主要问题
-
如何准确的定位到网络上的一台或者多台主机
-
找到主机之后如何进行通信
2.网络编程中的要素
-
ip和端口号 ip
-
网络通信协议 udp,tcp
3.万物皆对象
1.3 IP地址
ip地址:IntAddress
唯一定位一台网络上的计算机
127.0.0.1:本机localhost
IP地址的分类:
-
ipv4/ipv6
-
ipv4 127.0.0.1 4个字节组成 0-255 42亿个 30亿在北美 亚洲 4亿 2011年就用尽;
-
ipv6 本地链接 IPv6 地址. . . . . . . . : fe80::c83e:6b81:30f5:79ab%4 128位 ,8个无符号整数
-
-
公网(互联网)--私网(局域网)
-
ABCD类地址
-
192.168.xx.xx 局域网,专门给组织内使用
-
域名:记忆IP问题!
package com.zishi.lesson1; import java.net.InetAddress; import java.net.UnknownHostException; public class TestInetAddress { public static void main(String[] args) { try{ //查询本机地址 InetAddress inetAddress1 = InetAddress.getByName("127.0.0.1"); System.out.println(inetAddress1); InetAddress inetAddress2 = InetAddress.getByName("localhost"); System.out.println(inetAddress2); InetAddress inetAddress3 = InetAddress.getLocalHost(); System.out.println(inetAddress3); //查询网站ip地址 InetAddress inetAddress4 = InetAddress.getByName("www.baidu.com"); System.out.println(inetAddress4); System.out.println(inetAddress1.getAddress());//[B@1b6d3586 System.out.println(inetAddress2.getCanonicalHostName());//activate.navicat.com Canonical规范的 System.out.println(inetAddress3.getHostAddress());//192.168.137.1 System.out.println(inetAddress4.getHostName());//www.baidu.com } catch (UnknownHostException e) { e.printStackTrace(); } } }
1.4 端口Port
端口表示计算机上一个程序的进程;pid:进程id
-
不同的进程有不同的端口号!用来区分软件
-
被规定0~65535
-
TCP、UDP:65535*2 tcp:80 , udp:80 不冲突 单个协议下,端口号不冲突
-
端口分类
-
公有端口0~1023
-
HTTP:80
-
HTTPS:443
-
FTP:21
-
TELent:23
-
-
程序注册端口:1024~49151,分配给用户或客户端
-
Tomcat:8080
-
MySql:3306
-
Oracle:1521
-
-
动态、私有:49152
-
netstat -ano #查看多有端口 netstat -ano|findstr "5900" #查看指定端口 //findstr过滤,先查找过滤的事情 tasklist|findstr "8696" #查看指定端口的进程
这篇关于网络编程,概述,网络通信要素,ip地址,端口Port的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26结对编程到底难不难?答案在这里
- 2024-06-19《2023版Java工程师》课程升级公告
- 2024-06-15matplotlib作图不显示3D图,怎么办?
- 2024-06-1503-Loki 日志监控
- 2024-06-1504-让LLM理解知识 -Prompt
- 2024-06-05做软件测试需要懂代码吗?
- 2024-06-0514-ShardingSphere的分布式主键实现
- 2024-06-03为什么以及如何要进行架构设计权衡?
- 2024-05-31全网首发第二弹!软考2024年5月《软件设计师》真题+解析+答案!(11-20题)
- 2024-05-31全网首发!软考2024年5月《软件设计师》真题+解析+答案!(21-30题)