当前位置: 首页 > news >正文

Linux 网络编程 + 笔记

协议:一组规则

分层模型结构:

  • OSI七层模型:物理层、数据链路层、网络层、传输层、会话层、表示层、应用层
  • TCP/IP 4层模型:链路层/网络接口层、网络层、传输层、应用层
    • 应用层:http、ftp、nfs、ssh、telnet、
    • 传输层:TCP、UDP
    • 网络层:IP、ICMP、IGMP
    • 链路层:以太网帧协议、ARP

C/S模型和B/S模型

  • C/S模型:client-server
  • B/S模型:browser-server

网络传输流程:

  • 数据没有封装之前,是不能在网络中传递
  • 数据-》应用层-》传输层-》网络层-》链路层  --- 网络环境

以太网帧协议:

  • ARP协议:根据IP地址获取mac地址
  • 以太网帧协议:根据mac地址,完成数据包传输

IP协议:

  • 版本: IPv4、IPv6  -- 4位
  • TTL:time to live (设置数据包在路由节点中的跳转上限,每经过一个路由节点,该值-1, 减为0的路由,有义务将该数据包丢弃)
  • 源IP:32位 -- 4字节 
192.168.1.108 --- 点分十进制 IP地址(string)
  • 目的IP:32位--- 4字节

IP地址:可以在网络环境中,唯一标识一台主机

端口号:可以进行网络通信的一台主机上,唯一标识一个进程

IP地址+端口号:可以在网络环境中,唯一标识一个进程

UDP协议16位:源端口号     2^16 = 6553616位:目的端口号TCP协议16位:源端口号     2^16 = 6553616位:目的端口号32序号32确认序号6个标志位16位窗口大小       2^16 = 65536

网络套接字:socket

  • 一个文件描述符指向一个套接字(该套接字内部由内核借助两个缓冲区实现)
  • 在通信过程中,套接字一定是成对出现的

网络字节序:

  • 小端法:(pc本地存储)    高位存高地址,低位存低地址            int a = 0x12345678
  • 大端法:(网络存储)        高位存低地址,低位存高地址         
    htonl --> 本地--》网络 (IP)			192.168.1.11 --> string --> atoi --> int --> htonl --> 网络字节序htons --> 本地--》网络 (port)ntohl --> 网络--》 本地(IP)ntohs --> 网络--》 本地(Port)

 注意:htonl --> 本地 --> 网络(IP)

192.168.1.11 --> string --> atoi --> int --> htonl --> 网络字节序

IP地址转换函数

  1. inet_pton
  2. inet_ntop
  • 本地字节序(string IP) ---> 网络字节序 
// 本地字节序(string IP) ---> 网络字节序
int inet_pton(int af, const char *src, void *dst);af: AF_INET,AF_INET6src:传入,IP地址(点分十进制)dst:传出转换后的 网络字节序的 IP地址返回值:成功:   1异常:   0,说明src指向的不是一个有效的ip地址失败:  -1
NAMEinet_pton - convert IPv4 and IPv6 addresses from text to binary formSYNOPSIS#include <arpa/inet.h>int inet_pton(int af, const char *src, void *dst);DESCRIPTIONThis  function converts the character string src into a network addressstructure in the af address family, then  copies  the  network  addressstructure  to dst.  The af argument must be either AF_INET or AF_INET6.dst is written in network byte order.
  • 网络字节序  ---> 本地字节序(string IP) 
// 网络字节序  ---> 本地字节序(string IP)
const char *inet_ntop(int af, const void *src,char *dst, socklen_t size);af: AF_INET,AF_INET6src: 网络字节序IP地址dst: 本地字节序(string IP)size: dst的大小返回值: 成功: dst失败: NULL
NAMEinet_ntop - convert IPv4 and IPv6 addresses from binary to text formSYNOPSIS#include <arpa/inet.h>const char *inet_ntop(int af, const void *src,char *dst, socklen_t size);DESCRIPTIONThis  function  converts  the  network  address  structure src in the afaddress family into a character string.  The resulting string is  copiedto  the buffer pointed to by dst, which must be a non-null pointer.  Thecaller specifies the number of bytes available in  this  buffer  in  theargument size.
  • sockaddr地址结构: IP + Port  --> 在网络环境中唯一标识一个进程 
sockaddr地址结构: IP + Port  --> 在网络环境中唯一标识一个进程struct sockaddr_in addr;addr.sin_family = AF_INET;addr.sin_port = htons(8080);
#if 0int dst;inet_pton(AF_INET,"192.168.1.100",(void*)dst);   addr.sin_addr.s_addr = dst;
#else// 取出系统中有效的任意IP地址(二进制类型)addr.sin_addr.s_addr =  htonl(INADDR_ANY);bind(fd,(struct sockaddr*)&addr,sizeof(addr));

  • socket函数,创建一个套接字
socket函数#include <sys/socket.h>// 创建一个套接字int socket(int domain, int type, int protocol);domain: AF_INET,AF_INET6type: SOCK_STREAM,SOCK_DGRAMprotocol: 0返回值:成功: 新套接字所对应文件描述符失败: -1 errno
NAMEsocket - create an endpoint for communicationSYNOPSIS#include <sys/types.h>          /* See NOTES */#include <sys/socket.h>int socket(int domain, int type, int protocol);DESCRIPTIONsocket()  creates  an  endpoint  for  communication  and  returns a filedescriptor that refers to that endpoint.  The file  descriptor  returnedby  a  successful  call  will be the lowest-numbered file descriptor notcurrently open for the process.
  • bind函数 
#include <arpa/inet.h>
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);sockfd: socket 函数返回值struct sockaddr_in addr;addr.sin_family = AF_INET;addr.sin_port = htons(8080);addr.sin_addr.s_addr = htonl(INADDR_ANY);addr:传入参数(struct sockaddr*)&addraddrlen:sizeof(addr) 地址结构的大小返回值:成功: 0失败: -1 errno
NAMEbind - bind a name to a socketSYNOPSIS#include <sys/types.h>          /* See NOTES */#include <sys/socket.h>int bind(int sockfd, const struct sockaddr *addr,socklen_t addrlen);DESCRIPTIONWhen  a  socket  is  created  with  socket(2), it exists in a name space(address family) but has no address assigned to it.  bind() assigns  theaddress specified by addr to the socket referred to by the file descrip‐tor sockfd.  addrlen specifies the size, in bytes, of the address struc‐ture  pointed  to  by  addr.   Traditionally,  this  operation is called“assigning a name to a socket”.It is normally necessary to assign a local address using bind() before aSOCK_STREAM socket may receive connections (see accept(2)).
  • listen函数,设置同时与服务器建立连接的上限数(同时进行3次握手的客户端数量)
// 设置同时与服务器建立连接的上限数(同时进行3次握手的客户端数量)
int listen(int sockfd, int backlog);sockfd: socket 函数返回值backlog: 上限数值,最大值为128返回值:成功: 0失败: -1 errno
NAMElisten - listen for connections on a socketSYNOPSIS#include <sys/types.h>          /* See NOTES */#include <sys/socket.h>int listen(int sockfd, int backlog);DESCRIPTIONlisten()  marks  the  socket  referred to by sockfd as a passive socket,that is, as a socket that will be used  to  accept  incoming  connectionrequests using accept(2).The sockfd argument is a file descriptor that refers to a socket of typeSOCK_STREAM or SOCK_SEQPACKET.The backlog argument defines the maximum length to which  the  queue  ofpending  connections  for  sockfd  may  grow.   If  a connection requestarrives when the queue is full, the client may receive an error with  anindication  of  ECONNREFUSED  or,  if  the  underlying protocol supportsretransmission, the request may be ignored so that a later reattempt  atconnection succeeds.
  • accept函数,阻塞等待客户端建立连接,成功的话,返回一个与客户端成功连接的socket文件描述符
// 阻塞等待客户端建立连接,成功的话,返回一个与客户端成功连接的socket文件描述符
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);sockfd:socket 函数返回值addr:传出参数,成功与服务器建立连接的那个客户端的地址结构(IP+port)socklen_t client_addr_len = sizeof(addr);addrlen:传入传出  &client_addr_len入:addr的大小  出:客户端addr实际大小返回值:成功:能与客户端进行数据通信的 socket 对应的文件描述失败:-1,errno
NAMEaccept, accept4 - accept a connection on a socketSYNOPSIS#include <sys/types.h>          /* See NOTES */#include <sys/socket.h>int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);#define _GNU_SOURCE             /* See feature_test_macros(7) */#include <sys/socket.h>int accept4(int sockfd, struct sockaddr *addr,socklen_t *addrlen, int flags);DESCRIPTIONThe  accept()  system  call is used with connection-based socket types (SOCK_STREAM, SOCK_SEQPACKET).  It extractsthe first connection request on the queue of pending connections for the listening socket, sockfd, creates  a  newconnected  socket, and returns a new file descriptor referring to that socket.  The newly created socket is not inthe listening state.  The original socket sockfd is unaffected by this call.
  • connect函数
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);sockfd: socket 函数返回值struct sockaddr_in server_addr; // 服务器地址结构server_addr.sin_family = AF_INET;server_addr.sin_port = htons(8080);// 跟服务器bind时设定的 port 完全一致。inet_pton(AF_INET, "服务器IP地址", &server_addr.sin_addr.s_addr);addr:传入参数,服务器的地址结构addrlen:服务器的地址结构的大小返回值:成功: 0失败: -1,errno如果不使用bind绑定客户端地址结构,采用"隐式绑定".
NAMEconnect - initiate a connection on a socketSYNOPSIS#include <sys/types.h>          /* See NOTES */#include <sys/socket.h>int connect(int sockfd, const struct sockaddr *addr,socklen_t addrlen);DESCRIPTIONThe  connect()  system  call connects the socket referred to by the filedescriptor sockfd to the address specified by addr.  The  addrlen  argu‐ment  specifies  the size of addr.  The format of the address in addr isdetermined by the address space of the socket sockfd; see socket(2)  forfurther details.If  the socket sockfd is of type SOCK_DGRAM, then addr is the address towhich datagrams are sent by default, and the  only  address  from  whichdatagrams  are  received.   If  the  socket  is  of  type SOCK_STREAM orSOCK_SEQPACKET, this call attempts to make a connection  to  the  socketthat is bound to the address specified by addr.Generally,  connection-based protocol sockets may successfully connect()only once; connectionless protocol sockets may  use  connect()  multipletimes  to change their association.  Connectionless sockets may dissolvethe association by connecting to an address with the sa_family member ofsockaddr set to AF_UNSPEC (supported on Linux since kernel 2.2).

TCP 通信流程分析: 

TCP 通信流程分析:Server:1.socket()      创建socket2.bind()        绑定服务器地址结构3.listen()      设置同时与服务器建立连接的上限数(监听上限)4.accept()      阻塞监听客户端连接5.read(fd)      读socket获取客户端数据6.小 -- 大写     toupper()7.write(fd)     8.close()Client:1.socket()       创建socket2.connect()      与服务器建立连接3.write()        写数据到socket4.read()         读转换后的数据5.显示读取结果6.close()
  • server.c
#include <arpa/inet.h>  
#include <unistd.h>  
#include <pthread.h>#include <errno.h> 
#include <stdio.h>  
#include <stdlib.h>  
#include <string.h>  #include <ctype.h>  
#include <sys/socket.h>  #define SERVER_PORT 9527void sysErr(const char *msg) {perror(msg);exit(1);
}int main(int argc, char *argv[]) {int lfd = socket(AF_INET, SOCK_STREAM, 0);if (lfd == -1) sysErr("socket error");struct sockaddr_in server_addr;server_addr.sin_family = AF_INET;server_addr.sin_port = htons(SERVER_PORT);server_addr.sin_addr.s_addr = htonl(INADDR_ANY);//给服务器socket绑定地址结构int ret = bind(lfd,(struct sockaddr*)&server_addr,sizeof(server_addr));if(ret == -1) sysErr("bind error");// 设置监听上限  ret = listen(lfd,128);if(ret == -1) sysErr("listen error");struct sockaddr_in client_addr;socklen_t client_addr_len = sizeof(client_addr);//  获取客户端地址结构大小// 阻塞等待客户端连接请求 int cfd = accept(lfd,(struct sockaddr*)&client_addr,&client_addr_len);if(cfd == -1) sysErr("accept error");// 根据accept传出参数,获取客户端 ip 和 port  char client_IP[1024];printf("client ip:%s port:%d\n",inet_ntop(AF_INET,&client_addr.sin_addr.s_addr,client_IP,sizeof(client_IP)),ntohs(client_addr.sin_port));char buf[BUFSIZ];while(1) {ret = read(cfd,buf,sizeof(buf));write(STDOUT_FILENO,buf,ret);  // 写到屏幕查看// 转换为大写for(int i=0;i<ret;++i) {buf[i] = toupper(buf[i]); // 小写 -- 大写  }write(cfd,buf,ret);           // 将大写,写回给客户端}close(lfd);close(cfd);return 0;
}
  • client.c
#include <arpa/inet.h>
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>#include <stdio.h>
#include <stdlib.h>
#include <string.h>#define SERVER_PORT 9527void sysErr(const char* msg) {perror(msg);exit(EXIT_FAILURE);// EXIT_FAILURE	1
}int main(int argc, char const *argv[]) {int cfd = socket(AF_INET, SOCK_STREAM, 0);if(cfd == -1) sysErr("socket error");struct sockaddr_in server_addr; // 服务器地址结构server_addr.sin_family = AF_INET;server_addr.sin_port = htons(SERVER_PORT);inet_pton(AF_INET, "127.0.0.1", &server_addr.sin_addr.s_addr);int ret = connect(cfd, (struct sockaddr*)&server_addr, sizeof(server_addr));if(ret == -1) sysErr("connect error");int counter = 10;char buf[BUFSIZ];while(counter--) {char *msg = "hello server\n";write(cfd,msg,strlen(msg));ret = read(cfd,buf,sizeof(buf));write(STDOUT_FILENO,buf,ret);sleep(1);}close(cfd);return 0;
}
heheda@linux:~/Linux/test$ gcc server.c -o server -Wall -g
heheda@linux:~/Linux/test$ ./server 
heheda@linux:~/Linux/test$ gcc client.c -o client -Wall -g
heheda@linux:~/Linux/test$ ./client

未完待续~ 

相关文章:

Linux 网络编程 + 笔记

协议&#xff1a;一组规则 分层模型结构&#xff1a; OSI七层模型&#xff1a;物理层、数据链路层、网络层、传输层、会话层、表示层、应用层TCP/IP 4层模型&#xff1a;链路层/网络接口层、网络层、传输层、应用层 应用层&#xff1a;http、ftp、nfs、ssh、telnet、传输层&am…...

顺序表应用3:元素位置互换之移位算法

顺序表应用3&#xff1a;元素位置互换之移位算法 Description 一个长度为len(1<len<1000000)的顺序表&#xff0c;数据元素的类型为整型&#xff0c;将该表分成两半&#xff0c;前一半有m个元素&#xff0c;后一半有len-m个元素&#xff08;1<m<len)&#xff0c;借…...

Luogu P6066 [USACO05JAN] Watchcow S 题解 欧拉回路

题目链接&#xff1a;Luogu P6066 [USACO05JAN] Watchcow S 欧拉回路 题目描述&#xff1a; 给定一张无向图&#xff0c;输出任意一条从一号结点出发的欧拉回路&#xff08;欧拉回路指每条无向边来回经过且只经过一次&#xff09;&#xff0c;给定的图保证这样的欧拉回路存在。…...

计算机网络_1.6.3 计算机网络体系结构分层思想举例

1.6.3 计算机网络体系结构分层思想举例 1、实例引入&#xff08;用户在主机中使用浏览器访问web服务器&#xff09;2、从五层原理体系结构的角度研究该实例3、练习题 笔记来源&#xff1a; B站 《深入浅出计算机网络》课程 本节通过一个常见的网络应用实例&#xff0c;来介绍计…...

图论练习1

内容&#xff1a;&#xff0c;拆点&#xff0c;分层&#xff0c;传递&#xff0c;带限制的最小生成树 [HNOI2015]菜肴制作 题目链接 题目大意 有个限制&#xff0c;号菜肴在号前完成在满足限制的条件下&#xff0c;按照出菜( 是为了满足的限制 ) 解题思路 由限制&#xf…...

canvas设置图形各种混合模式,类似photoshop效果

查看专栏目录 canvas实例应用100专栏&#xff0c;提供canvas的基础知识&#xff0c;高级动画&#xff0c;相关应用扩展等信息。canvas作为html的一部分&#xff0c;是图像图标地图可视化的一个重要的基础&#xff0c;学好了canvas&#xff0c;在其他的一些应用上将会起到非常重…...

谷粒商城-P19

项目结构创建&提交到码云 数据库初始化 保持docker数据库一直打开 docker update redis --restartalways 连不上了&#xff0c;发现配置文件错了 换了一个配置文件。 快速开发 使用开源的脚手架 人人开源 (gitee.com) 使用renren-fast作为后台开发&#xff0c;使用…...

Vue3入门到实战笔记02

9. watch 作用&#xff1a;监视数据的变化&#xff08;和Vue2中的watch作用一致&#xff09;特点&#xff1a;Vue3中的watch只能监视以下四种数据&#xff1a; ref定义的数据。reactive定义的数据。函数返回一个值&#xff08;getter函数&#xff09;。一个包含上述内容的数组…...

CDN高防IP:技术解析与相关问题解答

在使用CDN高防IP技术的过程中&#xff0c;可能会遇到一些问题。下面是一些常见问题和相应的解答&#xff0c;希望能帮助读者更好地了解和使用CDN高防IP技术。 问题一&#xff1a;什么是CDN高防IP技术&#xff1f; 解答&#xff1a;CDN高防IP技术是一种通过将网站流量分散到多…...

【React】react组件传参

【React】react组件传参 一、props&#xff1a;父组件向子组件传参1、将普通的参数作为props传递2、将jsx作为props传递&#xff08;组件插槽&#xff09;&#xff08;1&#xff09;基础功能示例&#xff08;2&#xff09;进阶示例 二、自定义事件&#xff1a;子父组件向父组件…...

Vue/html中点击复制到剪贴板

1.使用JQ实现复制功能 html <div class"tran_one tran_yi"><div class"form-group"><textarea>文本</textarea></div><div class"form-group tran_group"><div class"tran_flex tran_left tran_co…...

MtfLive直播导航PHP源码,附带系统搭建教程

将自动采集斗鱼、虎牙、触手、YY、章鱼、电视直播按分类/关键词聚合&#xff0c;用户选择分类&#xff0c;可以观看到全网该关键词下正在直播的内容。 特点 PC站和H5移动站自适应 自动缓存&#xff0c;避免频繁抓取数据 自定义抓取采集规则&#xff0c;同时支持HTML和JSON …...

day19 初始HTML

什么是HTML HTML&#xff08;Hyper Text Markup Language&#xff09;超文本标记语言 超文本包括&#xff1a;文字、图片、音频、视频、动画等 HTML5&#xff0c;提供了一些新的元素和一些有趣的新特性&#xff0c;同时也建立了一些新的规则。这些元素、特性和规则的建立&…...

从编程中理解:退一步海阔天空

编程中&#xff0c;“退一步海阔天空”的理念指的是在面对问题时&#xff0c;有时过于纠结于细节或局部优化&#xff0c;反而会陷入困境。这时&#xff0c;如果能暂时放下手中的具体工作&#xff0c;从更高的层面或者换个角度来审视整个系统的设计和架构&#xff0c;可能会发现…...

【前沿技术杂谈:开源软件】引领技术创新与商业模式的革命

【前沿技术杂谈&#xff1a;开源软件】引领技术创新与商业模式的革命 开源软件如何推动技术创新开源软件的开放性和协作精神促进知识共享和技术迭代推动关键技术的发展开源软件与新技术的融合 开源软件的商业模式开源软件的商业模式将开源软件与商业软件相结合 开源软件的安全风…...

c# datatable 通过反射转成泛型list

在C#中&#xff0c;可以使用反射来将DataTable转换为泛型列表。下面是一个示例代码&#xff0c;展示了如何使用反射来实现这个转换过程&#xff1a; using System; using System.Collections.Generic; using System.Data;public class DataConverter {public List<T> Co…...

如何保证MySQL数据一致性

在当今大数据时代&#xff0c;数据库系统扮演着至关重要的角色&#xff0c;而MySQL作为一种流行的关系型数据库管理系统&#xff0c;在数据一致性方面拥有着丰富的机制和技术。下面简单的探讨MySQL是如何保证数据一致性的。 事务与ACID特性 要了解MySQL如何保证数据一致性&am…...

Android学习之路(27) ProGuard,混淆,R8优化

前言 使用java编写的源代码编译后生成了对于的class文件&#xff0c;但是class文件是一个非常标准的文件&#xff0c;市面上很多软件都可以对class文件进行反编译&#xff0c;为了我们app的安全性&#xff0c;就需要使用到Android代码混淆这一功能。 针对 Java 的混淆&#x…...

进程中线程使用率偏高问题排查

1. top命令查看CPU使用率高的进程 2. top -H -p 15931(进程PID) 查看进程下的线程 3. printf "%x\n" 17503(线程PID) 线程PID 10进制转16进制 0x445f 4. jstack -l 15931(JVM进程PID) 导出java进程栈信息&#xff0c;里面包含线程nid0x445f和所在的类&#xff0…...

【JavaEE进阶】 图书管理系统开发日记——肆

文章目录 &#x1f343;前言&#x1f38d;约定前后端交互接⼝&#x1f340;服务器代码实现&#x1f6a9;控制层&#x1f6a9;业务层&#x1f6a9;数据层 &#x1f334;前端代码的修改⭕总结 &#x1f343;前言 今天我们来实现修改图书模块 首先我们先来看一下&#xff0c;需要…...

conda相比python好处

Conda 作为 Python 的环境和包管理工具&#xff0c;相比原生 Python 生态&#xff08;如 pip 虚拟环境&#xff09;有许多独特优势&#xff0c;尤其在多项目管理、依赖处理和跨平台兼容性等方面表现更优。以下是 Conda 的核心好处&#xff1a; 一、一站式环境管理&#xff1a…...

基于ASP.NET+ SQL Server实现(Web)医院信息管理系统

医院信息管理系统 1. 课程设计内容 在 visual studio 2017 平台上&#xff0c;开发一个“医院信息管理系统”Web 程序。 2. 课程设计目的 综合运用 c#.net 知识&#xff0c;在 vs 2017 平台上&#xff0c;进行 ASP.NET 应用程序和简易网站的开发&#xff1b;初步熟悉开发一…...

Qt Widget类解析与代码注释

#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码&#xff0c;写上注释 当然可以&#xff01;这段代码是 Qt …...

ElasticSearch搜索引擎之倒排索引及其底层算法

文章目录 一、搜索引擎1、什么是搜索引擎?2、搜索引擎的分类3、常用的搜索引擎4、搜索引擎的特点二、倒排索引1、简介2、为什么倒排索引不用B+树1.创建时间长,文件大。2.其次,树深,IO次数可怕。3.索引可能会失效。4.精准度差。三. 倒排索引四、算法1、Term Index的算法2、 …...

CMake 从 GitHub 下载第三方库并使用

有时我们希望直接使用 GitHub 上的开源库,而不想手动下载、编译和安装。 可以利用 CMake 提供的 FetchContent 模块来实现自动下载、构建和链接第三方库。 FetchContent 命令官方文档✅ 示例代码 我们将以 fmt 这个流行的格式化库为例,演示如何: 使用 FetchContent 从 GitH…...

【Go语言基础【13】】函数、闭包、方法

文章目录 零、概述一、函数基础1、函数基础概念2、参数传递机制3、返回值特性3.1. 多返回值3.2. 命名返回值3.3. 错误处理 二、函数类型与高阶函数1. 函数类型定义2. 高阶函数&#xff08;函数作为参数、返回值&#xff09; 三、匿名函数与闭包1. 匿名函数&#xff08;Lambda函…...

解析奥地利 XARION激光超声检测系统:无膜光学麦克风 + 无耦合剂的技术协同优势及多元应用

在工业制造领域&#xff0c;无损检测&#xff08;NDT)的精度与效率直接影响产品质量与生产安全。奥地利 XARION开发的激光超声精密检测系统&#xff0c;以非接触式光学麦克风技术为核心&#xff0c;打破传统检测瓶颈&#xff0c;为半导体、航空航天、汽车制造等行业提供了高灵敏…...

sshd代码修改banner

sshd服务连接之后会收到字符串&#xff1a; SSH-2.0-OpenSSH_9.5 容易被hacker识别此服务为sshd服务。 是否可以通过修改此banner达到让人无法识别此服务的目的呢&#xff1f; 不能。因为这是写的SSH的协议中的。 也就是协议规定了banner必须这么写。 SSH- 开头&#xff0c…...

【实施指南】Android客户端HTTPS双向认证实施指南

&#x1f510; 一、所需准备材料 证书文件&#xff08;6类核心文件&#xff09; 类型 格式 作用 Android端要求 CA根证书 .crt/.pem 验证服务器/客户端证书合法性 需预置到Android信任库 服务器证书 .crt 服务器身份证明 客户端需持有以验证服务器 客户端证书 .crt 客户端身份…...

动态规划-1035.不相交的线-力扣(LeetCode)

一、题目解析 光看题目要求和例图&#xff0c;感觉这题好麻烦&#xff0c;直线不能相交啊&#xff0c;每个数字只属于一条连线啊等等&#xff0c;但我们结合题目所给的信息和例图的内容&#xff0c;这不就是最长公共子序列吗&#xff1f;&#xff0c;我们把最长公共子序列连线起…...