上一页 1 2 3 4 5 6 7 8 9 10 ··· 85 下一页
摘要: # UDP通信 # server.c #include <stdio.h> #include <string.h> #include <arpa/inet.h> #include <stdlib.h> #include <unistd.h> int main() { int lfd = socket 阅读全文
posted @ 2023-05-15 17:46 WTSRUVF 阅读(37) 评论(0) 推荐(0)
摘要: # select /* select阻塞函数,多次还是需要while,在新建客户端方面有没有都一样 因为accept多次也需要while 但在判断客户端是否有数据到来方面 使用了select就不需要创建多个线程或进程判断了,select可以批量判断 */ #include <stdio.h> #in 阅读全文
posted @ 2023-05-14 22:10 WTSRUVF 阅读(57) 评论(0) 推荐(0)
摘要: # 端口复用 阅读全文
posted @ 2023-05-11 15:21 WTSRUVF 阅读(39) 评论(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 阅读(32) 评论(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 阅读(30) 评论(0) 推荐(0)
摘要: 房间划分任务多次遇见wavefront propagation, 波前传播算法可用于为二维图中未标记的点分配适当的标签。 该算法背后的基本思想是从标记点开始,然后将它们的标签传播到相邻点,直到图中的所有点都被标记。以下是有关如何使用波前传播算法标记未标记点的分步指南: 首先识别图中所有标记的点。 这 阅读全文
posted @ 2023-05-10 21:51 WTSRUVF 阅读(458) 评论(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 阅读(29) 评论(0) 推荐(0)
摘要: # 字节序转换函数、IP地址转换函数 /* 网络字节序采用大端 网络通信时,需要将主机字节序转换成网络字节序(大端), 另外一个主机获取到数据后根据情况将网络字节序转换成主机字节序 #include <arpa/inet.h> // 转换32位数据,一般用于转换ip uint32_t htonl(u 阅读全文
posted @ 2023-05-09 11:01 WTSRUVF 阅读(26) 评论(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 阅读(18) 评论(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 阅读(30) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 85 下一页