日期:2014-05-16  浏览次数:21142 次

epoll_create failed: Function not implemented
最近在使用epoll时,出现了一个问题。
将程序移植到mips板子上时运行epoll监控程序时,出现如下打印信息:


socket done
bind done
listen done
epoll_create failed: Function not implemented


同样的源代码在pc上(x86)编译完后就运行正常,打印信息如下:


socket done
bind done
listen done
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
no socket ready for read within 5 secs
...


程序关于epoll部分的代码如下,请问是什么原因,如何解决这个问题,可以让epoll运行在板子上,谢谢。


#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <arpa/inet.h>
    #include <sys/epoll.h>
    #include <errno.h>

    #define DEFAULT_PORT    1984    //默认端口
    #define BUFF_SIZE       1024    //buffer大小

    #define EPOLL_MAXEVENTS 64      //epoll_wait的最多返回的events个数
    #define EPOLL_TIMEOUT   5000    //epoll_wait的timeout milliseconds

    //函数:设置sock为non-blocking mode
    void setSockNonBlock(int sock) {
        int flags;
        flags = fcntl(sock, F_GETFL, 0);
        if (flags < 0) {
            perror("fcntl(F_GETFL) failed");
            exit(EXIT_FAILURE);
        }
        if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) {
            perror("fcntl(F_SETFL) failed");
            exit(EXIT_FAILURE);
        }
    }

    int main(int argc, char *argv[]) {

        //获取自定义端口
        unsigned short int port;
        if (argc == 2) {
            port = atoi(argv[1]);
     &nbs