摘要: 1、select函数作为定时器使用 it_value.tv_sec = 0; it_value.tv_usec = 100000; select(1,NULL,NULL,NULL,&it_value); 上面的代码并不是立即返回而是等待100ms,可以作为定时器使用,并且准确度比sleep高。2、l... 阅读全文
posted @ 2015-10-18 22:29 allensun 阅读(5017) 评论(0) 推荐(0) 编辑
摘要: struct hostent { char FAR * h_name; /* official name of host */ char FAR * FAR * h_aliases; /* alias list */ sho... 阅读全文
posted @ 2015-10-18 22:22 allensun 阅读(1414) 评论(0) 推荐(0) 编辑
摘要: gethostbyname() -- 用域名或主机名获取IP地址 #include #include #include #include #include #include #include #include #include #include struct hostent ... 阅读全文
posted @ 2015-10-18 22:18 allensun 阅读(630) 评论(0) 推荐(0) 编辑
摘要: c_select 调用1. select系统调用select系统调用是用来让我们的程序监视多个文件描述符的状态变化的。程序会停在select这里等待,直到被监视的文件描述符有某一个或多个发生了状态改变。select()的机制中提供一fd_set的数据结构,实际上是一long类型的数组,每一个数组元素... 阅读全文
posted @ 2015-10-18 15:29 allensun 阅读(1388) 评论(0) 推荐(1) 编辑