导航

上一页 1 ··· 9 10 11 12 13

2021年4月3日 #

socket三种地址结构

摘要: /* <sys/socket.h> */ struct sockaddr { uint8_t sa_len; sa_family_t sa_family; char sa_data[14]; }; /* <netinet/in.h> */ struct sockaddr_in { uint8_t s 阅读全文

posted @ 2021-04-03 23:19 toughcactus 阅读(106) 评论(0) 推荐(0) 编辑

非阻塞connect

摘要: int flags = fcntl(sock_fd, F_GETFL, 0); fcntl(sock_fd, F_SETFL, flags|O_NONBLOCK); #else int imode = 1; ioctl(sock_fd, FIONBIO, &imode); 阅读全文

posted @ 2021-04-03 22:15 toughcactus 阅读(63) 评论(0) 推荐(0) 编辑

socket字符串,数值处理函数

摘要: inet_pton 字符串转为网络字节序整数,网络字节序可以直接用于sockaddr_in。 #include <sys/socket.h> #include <netinet/in.h> #include<arpa/inet.h> atoi 字符串是ASCII 将字符串转为整数 #include 阅读全文

posted @ 2021-04-03 20:35 toughcactus 阅读(69) 评论(0) 推荐(0) 编辑

valist

摘要: 最近在编写日志模块时,用到va_list,因为输出会包含不定数目的参数。 要求是在函数参数列表里,用...表明多个参数,但...之前必须得有一个参数。 声明va_list args, void logDebug(char *p, ...) { va_list args; /* 之所以...前要有一个 阅读全文

posted @ 2021-04-03 20:04 toughcactus 阅读(218) 评论(0) 推荐(0) 编辑

静态变量和全局变量浅析

摘要: 代码检视的时候,前辈建议全局变量添加g作前缀,静态变量添加s作前缀。 所谓全局变量,即在.c文件函数体外声明,可以在.h文件extern,这样,所有包含.h文件的情况下,均可使用该变量。 静态变量会添加static关键字,在.c文件函数体外声明,不会在.h文件extern。也就是说,只有.c文件内的 阅读全文

posted @ 2021-04-03 17:48 toughcactus 阅读(116) 评论(0) 推荐(0) 编辑

2021年4月1日 #

Mac上ggtags-find-tag-dwim失败问题

摘要: 公司用的windows emacs,在官网上下载了编译好的gnu global,配置好环境变量后,用的很好。 回到家做整理的时候,直接搞到第二天4点,洗完澡后不死心地在emacs china上发了求助帖,才去睡的觉。早上去到公司的时候,大牛已经回复我了,威武。昨天回家整个人都是懵的,也没打开电脑验证 阅读全文

posted @ 2021-04-01 22:00 toughcactus 阅读(57) 评论(0) 推荐(0) 编辑

iptables学习

摘要: netfilter是linux 防火墙,iptables是命令行工具。 netfilter的4张表 raw 原始报文 mangle 修改包 nat 网络地址转换 filter 包过滤 netfilter的5条链 PRE-ROUTING 和INPUT和FORWARD协作 检查DST? INPUT 本机 阅读全文

posted @ 2021-04-01 16:44 toughcactus 阅读(51) 评论(0) 推荐(0) 编辑

2021年3月30日 #

Emacs待整理

摘要: 一、文件内 | 批量替换字符串 M-x replace-string 二、输入法和编码 M-x set-input-method 设置输入法 lation-9-prefix 可以有上标 chinese-py-punct 默认 M-x revert-buffer-with-coding-system 阅读全文

posted @ 2021-03-30 15:54 toughcactus 阅读(83) 评论(0) 推荐(0) 编辑

上一页 1 ··· 9 10 11 12 13