易截截图软件、单文件、免安装、纯绿色、仅160KB

linux 2.6 kernel epoll

http://hi.baidu.com/j_fo/blog/item/a43fa60fa6e2f4eaab6457d5.html
Linux2.6内核epoll介绍
2008-11-05 16:35
http://blog.csdn.net/rstevens/archive/2007/10/30/1858067.aspx
http://hi.baidu.com/jmlover/blog/item/24c28b131e6b48d7f7039ee6.html
http://hi.baidu.com/jmlover/blog/item/e64df724f12926348744f91b.html
名词解释:man epoll之后,得到如下结果:
NAME
epoll - I/O event notification facility
SYNOPSIS
#include <sys/epoll.h>
DEscrīptION
epoll is a variant of poll(2) that can be used either as Edge or Level
Triggered interface and scales well to large numbers of watched fds.
Three system calls are provided to set up and control an epoll set:
epoll_create(2), epoll_ctl(2), epoll_wait(2).
An epoll set is connected to a file descrīptor created by
epoll_create(2).   Interest for certain file descrīptors is then
registered via
epoll_ctl(2). Finally, the actual wait is started by epoll_wait(2).
其实,一切的解释都是多余的,按照我目前的了解,EPOLL模型似乎只有一种格式,所以大家只要参考我下面的代码,就能够对EPOLL有所了解了,代码的解释都已经在注释中:
while (TRUE)
{
int nfds = epoll_wait (m_epoll_fd, m_events, MAX_EVENTS, EPOLL_TIME_OUT);//等待EPOLL事件的发生,相当于监听,至于相关的端口,需要在初始化EPOLL的时候绑定。
if (nfds <= 0)
continue;
m_bOnTimeChecking = FALSE;
G_CurTime = time(NULL);
for (int i=0; i<nfds; i++)
{
try
{
if (m_events[i].data.fd == m_listen_http_fd)//如果新监测到一个HTTP用户连接到绑定的HTTP端口,建立新的连接。由于我们新采用了SOCKET连接,所以基本没用。
{
OnAcceptHttpEpoll ();
}
else if (m_events[i].data.fd == m_listen_sock_fd)//如果新监测到一个SOCKET用户连接到了绑定的SOCKET端口,建立新的连接。
{
OnAcceptSockEpoll ();
}
else if (m_events[i].events & EPOLLIN)//如果是已经连接的用户,并且收到数据,那么进行读入。
{
OnReadEpoll (i);
}
OnWriteEpoll (i);//查看当前的活动连接是否有需要写出的数据。
}
catch (int)
{
PRINTF ("CATCH捕获错误\n");


相关文档:

linux nfs设置

使用过程中的心得:
一、解除目录映射关系
umount 目录可以解除关联关系
必须先在客户端umount,然后在服务器端停止nfs服务,以及修改/etc/exports,否则的话会导致df -h无法关闭
二、mount.nfs: Input/output error
解决:在客户端也需启动portmap
三、修改完毕/etc/exports文件之后,可以重启nfs服务,也可以使用exp ......

linux ip命令

ip 是个命令, ip 命令的功能很多!基本上它整合了 ifconfig 与 route 这两个命令,不过ip 的功能更强大! 如果您有兴趣的话,请自行 vi /sbin/ifup 就知道整个 ifup 就是利用 ip 这个命令来实现的。下面介绍一下使用方法
[root@linux ~]# ip [option] [动作] [命令]
参数:
option :设定的参数,主要有:
   ......

Linux中正确处理errno

errno变量(需include errno.h)会被赋一个整数值,不同的值表示不同的含义,
可以通过查看该值推测出错的原因。但是errno是一个数字,代表的具体含义
还要到errno.h中去阅读宏定义。有下面几种方法可以方便的得到错误信息
(一)
#include <stdio.h>
void perror(const char *s)
perror()用来将上一个函数发生错误的 ......

linux convert图像处理命令

 几个简单的应用。
  1、批量图像格式转换
  如果想将某目录下的所有jpg文件转换为png文件,只要在命令行模式下输入:
  for %f in (*.jpg) do convert “%f” “%~nf.png”
  2、对所有图像进行同一操作
  譬如,批量生成某目录下所有PNG图像文件的缩略图(大小为80×40):
  fo ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号