基于C++实现linux环境网卡抓包和流量统计分析
摘要:Packet定义 #include <stdint.h> #include <netinet/in.h> enum Direction { UNKNOWN = -1, INCOMING = 0, // Recv packet OUTGOING = 1, // Send packet }; struc
阅读全文
posted @
2025-08-23 22:19
umichan
阅读(91)
推荐(0)
C++倒序读取文件内容
摘要:需求:需要对系统日志进行监控,获取增量日志 ### 获取文件最后一行内容 ``` // 获取上一行行尾位置 int MovetoLineStart(std::fstream* fs) { fs->seekg(-1, std::ios_base::cur); for (int i = fs->tell
阅读全文
posted @
2023-08-16 19:15
umichan
阅读(382)
推荐(0)
Linux打包C++应用deb脚本
摘要:## 目录结构 ├── CMakeLists.txt ├── README.md ├── scripts │ └── build_deb.sh ├── src │ └── app.cpp └── VERSION ## 打包脚本 ```bash #! /bin/bash PROJECT_NAME="m
阅读全文
posted @
2023-06-13 11:13
umichan
阅读(124)
推荐(0)
Linux下计算CPU使用率和进程CPU占用
摘要:0.top指令和ps指令的CPU计算 top top指令显示为一段时间内的CPU使用率,通常为几秒 显示值可大于100%,表示多核占用的情况 用于排查CPU高负载进程 ps ps指令显示从开机到现在的平均CPU使用率 主要用于查看进程CPU资源占用 1.Linux下CPU使用率计算 1.1 获取CP
阅读全文
posted @
2023-05-24 15:39
umichan
阅读(3093)
推荐(0)
Windows安装mingw/gcc64位
摘要:先到mstorsjo/llvm-mingw下载mingw的压缩包 64位选下图框出的 下载之后解压放到任意位置,例如E:\mingw 然后配置环境变量 计算机-属性-高级系统设置-环境变量 在[系统变量]中找到Path,选择编辑,然后在写入mingw路径 以E:\mingw为例则写入E:\mingw
阅读全文
posted @
2023-01-14 12:23
umichan
阅读(578)
推荐(0)
C++编译问题,解决arm下链接静态库,引起的relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol错误
摘要:显示的完整错误如下: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `ZN2c43yml9free_implEPvmS1' which may bind externally can not be used when making a sh
阅读全文
posted @
2023-01-09 14:44
umichan
阅读(7901)
推荐(1)
C++ Linux下使用共享内存
摘要:在Linux下可以使用System V共享内存段实现共享内存,一共有4个API: 创建共享内存段或使用已经创建的共享内存段-shmget() 将进程附加到已经创建的共享内存段-shmat() 从已连接的共享内存段中分离进程-shmdt() 共享内存段上的控制操作-shmctl() 使用System
阅读全文
posted @
2022-08-15 15:39
umichan
阅读(1235)
推荐(0)
Qt实现无边框背景加深的对话框
摘要:// ui_frameless_dialog.h #pragma once #include <QWidget> #include <QMouseEvent> class FramelessDialog : public QWidget { Q_OBJECT public: FramelessDia
阅读全文
posted @
2022-07-29 19:29
umichan
阅读(192)
推荐(0)
C++实现简单的线程池
摘要:// thread_pool.h #pragma once #include <vector> #include <deque> #include <thread> #include <functional> #include <condition_variable> class ThreadPoo
阅读全文
posted @
2022-07-29 19:21
umichan
阅读(565)
推荐(0)
C++使用yaml-cpp解析yaml文件的方式
摘要:#include <yaml-cpp/yaml.h> #include <string> using namespace std; int main() { std::string file_path; // 读取yaml文件 YAML::Node yaml_node = YAML::LoadFil
阅读全文
posted @
2022-07-29 18:44
umichan
阅读(4658)
推荐(2)
C++ vscode调试CMake项目
摘要:CMake文件 在vscode工作目录下创建CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(test) set(CMAKE_CXX_STANDARD 11) add_executable(test test.cpp) C++文件
阅读全文
posted @
2022-07-27 15:14
umichan
阅读(713)
推荐(0)
C++使用CMake构建简单的grpc项目
摘要:编写proto文件并生成4个C++文件 首先编写proto文件,命名为test.proto,保存在工作目录下 syntax = "proto3"; package test.idl; message Student{ int32 id=1; string name=2; int32 score=3;
阅读全文
posted @
2022-07-21 14:38
umichan
阅读(1487)
推荐(0)
C++ Poco计算文件的MD5值
摘要:#include <Poco/DigestEngine.h> #include <Poco/DigestStream.h> #include <Poco/MD5Engine.h> #include <Poco/StreamCopier.h> #include <fstream> #include <
阅读全文
posted @
2022-07-20 16:38
umichan
阅读(349)
推荐(0)
C++ Poco 发起HTTP请求并获取响应
摘要:#include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/StreamCopier.h> #include <
阅读全文
posted @
2022-07-19 19:50
umichan
阅读(966)
推荐(0)
Qt实现可拉伸和可移动无边框的Widget
摘要:使用FramelessWindowHint设置之后Widget不能移动和拉伸,需要自己实现 setWindowFlags(Qt::FramelessWindowHint); .h文件 #pragma once #include <QWidget> class FramelessWidget : pu
阅读全文
posted @
2022-07-07 14:53
umichan
阅读(1287)
推荐(2)