假设我想避免linux内核处理传入数据包的开销,而是希望直接从用户空间获取数据包.我已经google了一下,似乎所有需要发生的事情就是使用带有一些套接字选项的原始套接字.是这样的吗?或者它比这更复杂?如果是这样,我可以谷歌或参考什么来实现这样的事情?
我目前正在使用一个代码示例,最初设计用于获取参数,然后在当前目录中搜索该参数,我试图通过替换"."来搜索另一个目录(/ dev/shm to exact). " 使用"/ dev/shm"但是当我搜索某些内容时代码没有任何内容*(请注意通配符).通配符搜索在当前目录中正常工作,所以我不认为这是外卡是问题,如果有人可以帮助我,虽然我真的很感激,谢谢!
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
static void lookup(const char *arg)
{
DIR *dirp;
struct dirent *dp;
if ((dirp = opendir(".")) == NULL) {
perror("couldn't open '.'");
return;
}
do {
errno = 0;
if ((dp = readdir(dirp)) != NULL) {
if (strcmp(dp->d_name, arg) != 0)
continue;
(void) printf("found %s\n", arg);
(void) closedir(dirp);
return;
}
} while (dp != NULL);
if (errno != 0)
perror("error reading directory");
else
(void) printf("failed to …
Run Code Online (Sandbox Code Playgroud)