ChinaUnix.net
相关文章推荐:

select程序

/* * name: tcp_slct.c * written by saodrin zhang for test */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define SVC_PORT 9999 int main_serv(int argc, char *argv[]); int main_clnt(int argc, char *argv[]); int main(int argc, char *argv[]) { int ret; if (argc == 1) ret = main_serv(a...

by winzipftp - 网络技术文档中心 - 2010-01-13 16:31:27 阅读(1915) 回复(0)

相关讨论

//服务器端 #include #include #include #include #include #include #include #include #include #include #include #include #include #define MAXLINE 1000 typedef struct client{ int fd; char *name; struct sockaddr_in addr; char *data; }CLIENT; void str_echo(CLIENT *client,char *buf,int len); void savadata(char *buf,int len,char *data); int main(int argc,char **argv) { int listenfd,connfd; struct soc...

by lhui_089 - 网络技术文档中心 - 2009-12-09 12:24:15 阅读(1087) 回复(0)

入门想写个聊天程序 socket tcp 方式 建立连接后项fork后想父进程读取客户端发来的信息 子进程读取标准输入然后发到客户端 可想而知 不行 看来socketfd 不能被不同的进程同时使用 看了看好像都用单进程select 看了别人的代码不太懂 能不能通俗的解释下select的机理 或者说还有什么其他的方法

by houtinghua - C/C++ - 2012-11-27 14:55:40 阅读(1967) 回复(5)

在网络程序中,一个进程同时处理多个文件描述符是很常见的情况。select()系统调用可以使进程检测同时等待的多个I/O设备,当没有设备准备好时,select()阻塞,其中任一设备准备好时,select()就返回。 select()的调用形式为: #include #include int select(int maxfd, fd_set *readfds, fd_set *writefds, fe_set *exceptfds, const struct timeval *timeout); select的第一个参数是文件描述符集中要被检测的比特数,这个值必...

by phillipls - Linux文档专区 - 2008-08-30 16:22:20 阅读(675) 回复(0)

select()函数写的通讯程序 什么是异步通讯? 就是通讯任意一方可以任意发送消息,有消息来到时会收到系统提示去接收消息。 这里要用到select函数。使用步骤如下: 1、设置一个集合变量,用来存放所有要判断的句柄(file descriptors:即我们建立的每个socket、用open打开的每个文件等) 2、把需要判断的句柄加入到集合里 3、设置判断时间 4、开始等待,即select 5、如果在设定的时间内有任何句柄状态变化了就马上返回,并把...

by I-linux - Linux文档专区 - 2008-03-25 22:17:02 阅读(543) 回复(0)

我用C API写程序,执行select语句后,大多数情况下好的,但是有些时候程序会报无记录,但数据库中明显有记录,一定要重复执行几次后才能执行成功,请问是什么原因造成的。 MYSQL数据库版本是5.22

by jinmiaobis - MySQL - 2006-12-08 16:36:38 阅读(1430) 回复(7)

[code]$ cat pipe.c #include select.h> #include #include #include int fdctl[2];// 这个管道在建立线程之前建立。创建线程之后,两个线程各连接其中一端。因为不存在 fork 导致的 fd 复制,所以不需要像普通多进程环境一样 close 一端 // 控制线程,使用 fdctl[0] void *thfun( void *arg ) { int i; for ( i = 0; i < 3; ++i ) { printf( "%d sec\n", i ); sleep...

by wolf0403 - 程序开发 - 2007-01-05 15:35:36 阅读(3077) 回复(11)

[code]$ cat pipe.c #include select.h> #include #include #include int fdctl[2];// 这个管道在建立线程之前建立。创建线程之后,两个线程各连接其中一端。因为不存在 fork 导致的 fd 复制,所以不需要像普通多进程环境一样 close 一端 // 控制线程,使用 fdctl[0] void *thfun( void *arg ) { int i; for ( i = 0; i < 3; ++i ) { printf( "%d sec\n", i ); sleep...

by wolf0403 - Linux环境编程 - 2014-06-24 14:38:31 阅读(17214) 回复(14)

Pro*c怎么写一个select程序?通过该程序可以取得任意表的数据,结果是规整的? 如以逗号做分隔符: 123,asdddd,hasdfk123 谢谢!!

by anber45 - C/C++ - 2003-05-07 18:40:13 阅读(909) 回复(1)

一个服务器可对应多个客户端,经测试,服务器可以跟多个客户端交互,只是只能输入输出一条信息,希望大侠帮我看看,谢谢 server.c #include #include #include #include #include #include #include #include #include #include #include #define MAX_BUF_SIZE 1024 #define MAX_LISTEN...

by shenxiaocheng - C/C++ - 2009-07-09 16:36:15 阅读(2316) 回复(4)

我一直坚信,如果不是处理大规模客户端连接,是不需要使用epoll和IOCP的。我倾向于简单的东西,所以我一直用着select。一直以来,我的网络程序结构就是在每一帧的开始select,有什么消息就处理一下,然后跑程序的主逻辑。我觉得这个结构挺好,单线程,简单、明了、优雅。不过最近有头儿告诉我,这个事情虽然可以,但是感觉上不太对头,网络组件的工作应该是独立的,不可以占用主逻辑的时间。好吧,我改成多线程就是了。一个主线程...

网络技术

by sss0213 - 网络技术文档中心 - 2009-01-12 13:44:38 阅读(1013) 回复(0)