摘要:
举个栗子 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <sys/types.h> 5 #include <pthread.h> 6 #include <errno.h> 7 #include 阅读全文
2018年5月13日 #
摘要:
信号量API #include <semaphore.h> 2 //等待互斥量(原子操作) 3 int sem_wait(sem_t *serm); 4 //通知互斥量加一 5 int sem_post(sem_t *sem); 基于信号量与互斥锁实现的生产者和消费者 1 #include <std 阅读全文
2018年5月10日 #
摘要:
(转载自 http://blog.sina.com.cn/s/blog_6b3765230100lazj.html) ulimit -c 输出如果为0,则说明coredump没有打开 ulimit -c 输出如果为unlimited,则说明coredump已打开 通过 ulimit -c unlim 阅读全文
摘要:
http://blog.csdn.net/centerpoint/article/details/38542719 根本原因: Linux默认启用了反向路由检查 如果2个网卡在一个Lan里面,那么服务器可能从eth0或者eth1发现网关, 如果一个包从eth0进入了, 而网关在eth1上, 那么从e 阅读全文
2018年5月6日 #
摘要:
void *mmap(void *addr,size_t len,int prot,int flags, int fd,off_t offset); prot:保护方式 PROT_READ:页面可读 PROT_WRITE:页面可写 PROT_EXEC: PROT_NONE: fiags: MAP_S 阅读全文
摘要:
互斥:矛盾 同步:协作 消息队列 #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> int msgget(key_t key,int msgflg); int msgctl(int msgid,int cmd,stuct 阅读全文
2018年4月30日 #
摘要:
往一个已经接受FIN的套接中写是允许的,接受到FIN仅仅代表对方不再发送数据。 在收到RST段之后,如果在调用write就 会产生SIGPIPE信息,对于这个信号的处理我们通常 解决方法 signal(SIGPIPE,SIG_ING) 阅读全文
摘要:
1 fd_set rset; 2 FD_ZERO(&rset); 3 4 int nready; 5 int maxfd; 6 int fd_stdin = fileno(stdin); 7 if(fd_stdin > sock) 8 { 9 maxfd = fd_stdin; 10 } 11 el 阅读全文
2018年4月27日 #
摘要:
read,write与recv,send readline实现 用readline实现回射客户、服务器 getsockname ,getpeername gethostname,gethostbyname,gethostbyaddr 1 #include <stdio.h> 2 #include < 阅读全文