-
大小: 111KB文件类型: .gz金币: 1下载: 0 次发布日期: 2021-06-09
- 语言: 其他
- 标签: libnids-1.18
资源简介
libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz libnids-1.18.tar.gz
代码片段和文件信息
/*
This is an example how one can use nids_getfd() and nids_next() functions.
You can replace printall.c‘s function main with this file.
*/
#include
#include
#include
int
main ()
{
// here we can alter libnids params for instance:
// nids_params.n_hosts=256;
int fd;
int time = 0;
fd_set rset;
struct timeval tv;
if (!nids_init ())
{
fprintf(stderr“%s\n“nids_errbuf);
exit(1);
}
nids_register_tcp (tcp_callback);
fd = nids_getfd ();
for (;;)
{
tv.tv_sec = 1;
tv.tv_usec = 0;
FD_ZERO (&rset);
FD_SET (fd &rset);
// add any other fd we need to take care of
if (select (fd + 1 &rset 0 0 &tv))
{
if (FD_ISSET(fd&rset) // need to test it if there are other
// fd in rset
if (!nids_next ()) break;
}
else
fprintf (stderr “%i “ time++);
}
return 0;
}
- 上一篇:杭电计算机组成原理复习卷
- 下一篇:计算机组成原理课程设计-硬布线加中断ABEL代码
评论
共有 条评论