c/c++(c++和网络编程)日常积累(二)

Linux下C编程通过宏定义打开和关闭调试信息

https://www.cnblogs.com/robinsons/p/3667032.html

https://blog.csdn.net/u013457167/article/details/50759811?utm_source=blogxgwz2

 

阻塞,非阻塞,同步,异步

 https://www.jianshu.com/p/b8203d46895c

IO多路复用的三种机制Select,Poll,Epoll

https://www.jianshu.com/p/397449cadc9a

 

Socket中SO_REUSEADDR详解

1、一般来说,一个端口释放后会等待两分钟之后才能再被使用,SO_REUSEADDR是让端口释放后立即就可以被再次使用。

SO_REUSEADDR用于对TCP套接字处于TIME_WAIT状态下的socket,才可以重复绑定使用。server程序总是应该在调用bind()之前设置SO_REUSEADDR套接字选项。TCP,先调用close()的一方会进入TIME_WAIT状态

.......

https://blog.csdn.net/u010144805/article/details/78579528

C++ 11 左值,右值,左值引用,右值引用,std::move

https://blog.csdn.net/xiaolewennofollow/article/details/52559306

 

 如何在C/C++中调用Shell脚本

http://baozh.github.io/2013-11/how-to-call-shell-script-in-c-plus-plus-program/

 孤儿进程和僵尸进程

 https://www.cnblogs.com/lfri/p/12575637.html

 

 c++ split分割字符串实现

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
void split(const string& s,vector<int>& sv,const char flag = ' ') {
    sv.clear();
    istringstream iss(s);
    string temp;

    while (getline(iss, temp, flag)) {
        sv.push_back(stoi(temp));
    }
    return;
}

TCP的TIME_WAIT

https://www.cnblogs.com/zhenbianshu/p/10637964.h

 

linux管理时间

https://blog.csdn.net/liumiaocn/article/details/79250793

https://www.cnblogs.com/pipci/p/12833228.html

Linux 关闭系统时间同步

https://blog.csdn.net/cb1576351/article/details/106040844

源于一次项目需要修改系统时间,但是每次修改后又被同步回网络时间,找了好久发现是这个
原因:
NTP即Network Time Protocol(网络时间协议),是一个互联网协议,用于同步计算机之
间的系统时钟。timedatectl程序可以自动同步Linux系统时钟到使用NTP的远程服务器(大部
分linux系统自带ntp服务而不带ntp client,所以纠结了半天找不到为什么都没装NTP每次改
了时间又被同步回网络时间去了)。
1、timedatectl命令:
timedate
Local time: 三 2017-07-05 10:57:53 CST
Universal time: 三 2017-07-05 02:57:53 UTC
Timezone: Asia/Chongqing (CST, +0800)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
2、开启关闭ntp
timedatectl set-ntp true/false
其它
查找和设置Linux本地时区
1.显示系统的当前时间和日期
timedatectl status
结果中RTC time就是硬件时钟的时间。
2.Linux系统上的time总是通过系统的timezone设置的,查看当前时区:
timedatectl | grep Time
3.查看所有可用的时区:
timedatectl list-timezones
timedatectl list-timezones | egrep -o “Europe/L.*”
timedatectl list-timezones | egrep -o “America/N.*”
5.在Linux中设置本地时区,使用set-timezone开关:
timedatectl set-timezone “Asia/shagnhai
5.在Linux中设置本地时区,使用set-timezone开关:
timedatectl set-timezone “Asia/shagnhai
7.只设置日期的话可以使用set-time开关以及YY:MM:DD(年,月,日)的日期格式。
timedatectl set-time 20151120
8.设置日期和时间:
timedatectl set-time '16:10:40 2015-11-20
9.设置硬件时钟为UTC可以使用 set-local-rtc boolean-value选:
首先确定硬件时钟是否设置为本地时区:
9.设置硬件时钟为UTC可以使用 set-local-rtc boolean-value选:
首先确定硬件时钟是否设置为本地时区:
timedatectl | grep local
将硬件时钟设置为本地时区:
timedatectl set-local-rtc 1
将硬件时钟设置为UTC:
timedatectl set-local-rtc 0

 

C语言 用http post方式 上传json数据流程参考

 https://blog.csdn.net/qq_36072126/article/details/103836282

创建json结构数据   

my_buff就是最后要post的content
cJSON *usr ;
usr=cJSON_CreateObject(); //创建根数据对象
 cJSON_AddStringToObject(usr,"brand",ETC_baseinfo.brand);                    //厂家型号
 cJSON_AddStringToObject(usr,"deviceIP",ETC_baseinfo.deviceIP);               //车辆检测器IP地址
 cJSON_AddStringToObject(usr,"deviceId",ETC_baseinfo.deviceId);                        //设备编号
 cJSON_AddNumberToObject(usr,"devicePort",ETC_baseinfo.devicePort);                        //车辆检测器Port端口
 cJSON_AddStringToObject(usr,"gantryId",ETC_baseinfo.gantryId);         //门架编号
 cJSON_AddStringToObject(usr,"serverAddress",ETC_baseinfo.serverAddress); //车辆检测器服务地址
 cJSON_AddStringToObject(usr,"stateTime",ETC_baseinfo.stateTime);     //数据生成时间
  char *out = cJSON_Print(usr); //将json形式打印成正常字符串形式
 printf("out old string:
%s
",out);
 free(out);
 char *out2 = cJSON_PrintUnformatted(usr);
 sprintf(my_buff,"%s",out2);
 free(out2);
 cJSON_Delete(usr); // 释放内存

json库nlohmann简单使用教程,快速入手,完成json对象的构建,从STL构造json,以及序列化和反序列化操作,二进制写入、读取本地数据

 https://blog.csdn.net/u011341856/article/details/108797920

 

 

原文地址:https://www.cnblogs.com/kongweisi/p/14278171.html