ChinaUnix.net
相关文章推荐:

tcp select

#ifndef _ALL_H #define _ALL_H // ANSC C/C++ #include #include #include #include #include // linux #include #include #include #include #include #include #include #include // time #include #include #include // micro //#define OutErrStr(info) (printf("Error : %s\n", info)) //#define OutErrInt(info) (printf("Error : %d\n", info)) #define BUFF_SIZE 1024 * 1 #endif // t...

by danforn - Linux文档专区 - 2008-11-10 13:14:41 阅读(695) 回复(0)

相关讨论

tcp.c文件的tcp_select函数 978计划工作组 2009-8-25 1函数源码 /* * Wait for a tcp event. * * Note that we don't need to set "sk->inuse", as the upper select layers * take care of normal races (between the test and the event) and we don't * go look at any of the socket buffers directly. */ static int tcp_select(struct sock *sk, int sel_type, select_table *wait) { if (sk->stat...

by 978计划 - Linux文档专区 - 2009-08-25 15:24:03 阅读(960) 回复(0)

以前我编写socket程序,都是用的阻塞的方法,刚看了一篇文章,学会了select在udp服务器中的用法,但是tcp服务器中我该如何用呢,谁能告诉我一个框架啊,谢谢. accept是阻塞的,我必须得在accept之间调用select?

by luojiafeng1984 - C/C++ - 2007-03-08 15:43:24 阅读(4502) 回复(2)

tcp.c文件的tcp_listen_select函数 978计划工作组 2009-8-25 1函数源码 /* * LISTEN is a special case for select.. */ static int tcp_listen_select(struct sock *sk, int sel_type, select_table *wait) { if (sel_type == SEL_IN) { int retval; sk->inuse = 1; retval = (tcp_find_established(sk) != NULL); release_sock(sk); if (!re...

by 978计划 - Linux文档专区 - 2009-08-25 10:56:59 阅读(1074) 回复(0)

tcp.c文件的tcp_select_window函数 978计划工作组 2009-7-30 1函数源码 int tcp_select_window(struct sock *sk) { int new_window = sk->prot->rspace(sk); if(sk->window_clamp) new_window=min(sk->window_clamp,new_window); /* * Two things are going on here. First, we don't ever offer a * window less than min(sk->mss, MAX_WINDOW/2). This is the...

by 978计划 - Linux文档专区 - 2009-07-30 15:15:57 阅读(882) 回复(0)

本帖最后由 iw1210 于 2013-01-21 14:27 编辑 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 用select函数等待tcp数据(readfds和writefds参数都是socket描述符集),如果有新的socket链接,怎么把这个新的socket描述符加入select中最好?

by iw1210 - C/C++ - 2013-01-21 17:04:41 阅读(1881) 回复(5)

本帖最后由 nameofhsw 于 2013-05-14 10:39 编辑 具体如下: 1、建立套接字,绑定,设置非阻塞,然后开始监听 2、FD_ZERO(&m_rfd); FD_SET(listensock,&m_rfd); while(1){ int ret; pthread_t id; struct timeval timeOut; int m_dsize = listensock+1; timeOut.tv_sec = 60; timeOut.tv_usec = 0; //printf("+++++++++++++wait for connection+++++++++++++++\n"); //prin...

by nameofhsw - Linux环境编程 - 2013-05-17 12:27:41 阅读(4072) 回复(6)

本帖最后由 iw1210 于 2013-03-27 16:21 编辑 如果select函数的exceptfds参数是tcp连接的socket文件描述符集合,函数返回后在exceptfds 里能判断某个tcp连接已经断开了么?

by iw1210 - C/C++ - 2013-03-29 13:47:37 阅读(6832) 回复(23)

现在一个客户端程序接收服务端程序返回的消息,出现时好时坏的情况(tcp连接) 客户端发送请求包后,用select函数进行探测,如果有数据再recv接收。 相应的代码如下: int tcpRecv(int sockfd, char *buf, int len, int nFlag) { char *ptr ; int nbytes = 0; int left; fd_set fd; struct timeval timeout; int i, nFileFlag; int retv, retry; retry = 0; nbytes = 0; ptr = buf + nb...

by alloney - 网络技术 - 2009-12-17 18:50:47 阅读(2174) 回复(0)

现在一个客户端程序接收服务端程序返回的消息,出现时好时坏的情况(tcp连接)\r\n\r\n客户端发送请求包后,用select函数进行探测,如果有数据再recv接收。\r\n相应的代码如下:\r\nint tcpRecv(int sockfd, char *buf, int len, int nFlag)\r\n{\r\n char *ptr ;\r\n int nbytes = 0;\r\n int left;\r\n fd_set fd;\r\n struct timeval timeout;\r\n int i, nFileFlag;\r\n int retv, retry;\r\n\r\n ret...

by alloney - 企业网管技术交流区 - 2009-12-17 18:50:47 阅读(3705) 回复(0)

现在一个客户端程序接收服务端程序返回的消息,出现时好时坏的情况(tcp连接) 客户端发送请求包后,用select函数进行探测,如果有数据再recv接收。 相应的代码如下: int tcpRecv(int sockfd, char *buf, int len, int nFlag) { char *ptr ; int nbytes = 0; int left; fd_set fd; struct timeval timeout; int i, nFileFlag; int retv, retry; retry = 0; nbytes = 0; ptr = buf + nb...

by alloney - C/C++ - 2009-12-17 18:49:20 阅读(1798) 回复(0)