# 2407暑假班
**Repository Path**: yinyezheng/2407-summer-class
## Basic Information
- **Project Name**: 2407暑假班
- **Description**: 网络编程 + C++ 代码
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2025-01-15
- **Last Updated**: 2025-01-15
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 准备内容
## 如何创建代码模板

搜索json

如果搜不到 则自己创建一个

将下面的内容放到 c.json 文件中
### C 代码模版
```json
{
"C codes": {
"scope": "c", // 在哪些语言中生效
"prefix": "cm", // 自定义名称
"body": [
"#include
",
"",
"int main(int argc, char const *argv[])",
"{",
"\t$0", // $0 代表光标位置
"\t",
"\treturn 0;",
"}",
],
"description": "c语言自定义模板"
}
}
```
### C++ 代码模版
将下面的内容放到 cpp.json 文件中
```json
{
"start c code": {
"prefix": "cpp",
"body": [
"#include ",
"#include ",
"",
"using namespace std;",
"",
"int main(int argc, char const *argv[])",
"{",
"\t",
"\tcout << \"hello world\" << endl;$0",
"\t",
"\treturn 0;",
"}",
"",
],
"description": "生成一个基本的 C++ 程序"
}
}
```
### 准备head.h文件
head.h文件内容
```c
#ifndef __HEAD_H__
#define __HEAD_H__
// 头文件
#include
#include
#include
#include
#include
#include
#include
// 文件io
#include
#include
#include
#include
#include
#include
// 进程
#include
#include
#include
#include
#include
// IPC机制
#include
#include
#include
#include
// 标准错误
#define ERRLOG(STR) do \
{\
printf("%s 文件 %s 行 %d 错误:%s\n" , STR , __FILE__ , __LINE__ , strerror(errno) );\
} while (0);
#endif
```
### 如何全局访问 head.h 文件
```shell
# 1 创建文件
$ touch head.h
# 2 将上面的文件内容复制到 head.h 中
# 3 将 head.h 文件移动到 /usr/include 目录下
$ sudo mv head.h /usr/include/
# 4 修改 head.h 文件权限
sudo chmod 0666 /usr/include/head.h
```
## git 自动推送
linux 下 git 的安装
```shell
sudo apt-get install git
```
步骤如下
### 1 绑定公钥
```shell
# 1 绑定ssh 公钥 绑定linux 和 gitee 的公钥
# 在linux 中输入 以下指令 创建 ssh 公秘钥
linux:~$ ssh-keygen -t rsa
# 会出现以下内容直接三个回车即可
Generating public/private rsa key pair.
Enter file in which to save the key (/home/student/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/student/.ssh/id_rsa.
Your public key has been saved in /home/student/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RAWcRj9btk/1CfCGdItyXdZ08q/eEDeP6P88T2V1w/o student@student-machine
The key's randomart image is:
+---[RSA 2048]----+
| o++.o ..++|
| .+.. B =oo|
| ...o+o* o=|
| . o=..o.B|
| S . ..oo*|
| +.*+|
| . =Eo|
| . . * |
| ..o.B|
+----[SHA256]-----+
```
先在linux 中获取公钥
```shell
# 将公钥放到 gitee 中
# 输入指令 可以获取 linux中的 公钥
linux:~$ cat ~/.ssh/id_rsa.pub
```
将获取 的公钥 放入到gitee 中
1 点击设置

2 点击ssh公钥

3 生成的公钥粘贴进去

完成公钥对接
### 2 获取仓库的ssh
```shell
# 配置用户名和邮箱
git config --global user.name "your name"
git config --global user.email "your email"
# 创建一个新文件夹 工作区
# 创建工作区文件夹
mkdir C++_Code
cd C++_Code/
# 创建 .git 文件
git init
# 绑定远程地址
# 注意 绑定的地址 是ssh 地址 不是 https 地址
# 如果 已经绑定了 https 则直接运行下面这一行 会把原来的连接进行覆盖
# ssh_url 换成你自己仓库 的 shh 地址
git remote add origin ssh_url
```
方法二

```
直接克隆
这个命令 直接从git 上获取
git clone [url]
克隆完成之后就可以直接使用
```
### 3 制作脚本
脚本的编写
```shell
# 编写前的准备
mkdir ~/.bin
cd ~/.bin
touch git_push
chmod 0777 git_push
# 修改环境变量
code ~/.bashrc
# 如果 code 不能使用 则 使用vim
vim ~/.bashrc
# 然后在 .bashrc 文件最后面 添加一行
# 注意 $HOME/.bin:$PATH 路径和你.bin 路径要一样
export PATH="$HOME/.bin:$PATH"
# 运行.bashrc
source ~/.bashrc
# 脚本的内容
# 进入工作区
cd /home/student/1111
pwd
git add .
git commit -m "更新"
git push origin master
```
# 拆包 TCP
## 数据链路层
目的MAC地址 源 MAC 地址 类型

## 网络层数据
数据结构

抓包分析

## 传输层
