上一页 1 2 3 4 5 6 7 8 ··· 83 下一页
摘要: # 端口复用 阅读全文
posted @ 2023-05-11 15:21 WTSRUVF 阅读(31) 评论(0) 推荐(0) 编辑
摘要: /* 多线程实现并发服务器 主线程负责接收 子线程负责处理 */ #include <stdio.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <un 阅读全文
posted @ 2023-05-11 11:23 WTSRUVF 阅读(23) 评论(0) 推荐(0) 编辑
摘要: # server /* 多进程实现并发服务器 主进程负责接收 子进程负责处理 */ #include <stdio.h> #include <arpa/inet.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> #in 阅读全文
posted @ 2023-05-11 11:23 WTSRUVF 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 房间划分任务多次遇见wavefront propagation, 波前传播算法可用于为二维图中未标记的点分配适当的标签。 该算法背后的基本思想是从标记点开始,然后将它们的标签传播到相邻点,直到图中的所有点都被标记。以下是有关如何使用波前传播算法标记未标记点的分步指南: 首先识别图中所有标记的点。 这 阅读全文
posted @ 2023-05-10 21:51 WTSRUVF 阅读(191) 评论(0) 推荐(0) 编辑
摘要: # TCP通信流程 # 四次挥手半关闭状态 # server /* #include <sys/types.h> #include <sys/socket.h> int socket(int domain, int type, int protocol); 功能:创建一个套接字 参数: domain 阅读全文
posted @ 2023-05-10 10:39 WTSRUVF 阅读(19) 评论(0) 推荐(0) 编辑
摘要: # 字节序转换函数、IP地址转换函数 /* 网络字节序采用大端 网络通信时,需要将主机字节序转换成网络字节序(大端), 另外一个主机获取到数据后根据情况将网络字节序转换成主机字节序 #include <arpa/inet.h> // 转换32位数据,一般用于转换ip uint32_t htonl(u 阅读全文
posted @ 2023-05-09 11:01 WTSRUVF 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 有几个线程就有几个除互斥信号之外的信号量,每个线程等待自己的信号量有位置, 并最后给其他信号量位置。初始时,生产者的值非0,消费者的值为0。 /* #include <semaphore.h> int sem_init(sem_t *sem, int pshared, unsigned int va 阅读全文
posted @ 2023-05-07 09:29 WTSRUVF 阅读(14) 评论(0) 推荐(0) 编辑
摘要: # 互斥锁 /* #include <pthread.h> int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); 功能:初始化一个互斥变量mutex 参数: 阅读全文
posted @ 2023-05-06 11:54 WTSRUVF 阅读(20) 评论(0) 推荐(0) 编辑
摘要: # pthread_join /* #include <pthread.h> int pthread_join(pthread_t thread, void **retval); 功能:和一个已经终止的线程进行连接 回收线程的资源 阻塞函数,调用一次只能回收一个线程 任何线程都可以wait其它线程一 阅读全文
posted @ 2023-05-04 10:58 WTSRUVF 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 拥有线程程序的编译需要加 -pthread gcc a.c -o a -pthread /* #include <pthread.h> int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_ro 阅读全文
posted @ 2023-05-02 11:24 WTSRUVF 阅读(12) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 83 下一页