Git Product home page Git Product logo

libev's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libev's Issues

can this project build on windows?

I want to build libev on windows,but got some trouble when I try to do this.can this project be done or do you have any good Suggestions? thanks.

libev have some bug?

i have write a code:

#include <stdio.h>
#include <unistd.h>
#include<arpa/inet.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>

ev_io stdin_watcher;
ev_timer timeout_watcher;
static void timeout_cb (EV_P_ ev_timer *w, int revents) ;

static void udp_cb (EV_P_ ev_io *w, int revents)
{
        char buf[101] = {0};
        read(w->fd,buf,100);
        printf("read data---->%s\n",buf);
        ev_io_stop (EV_A_ w);
        ev_break (EV_A_ EVBREAK_ALL);
}

static int flag = 0;
struct ev_loop *loop;

static void timeout_cb (EV_P_ ev_timer *w, int revents)
{
        if(flag == 0){
                sleep(30);
                flag = 1;
        }
        ev_timer_stop (loop, w);
        ev_timer_set (w, 1, 0.0);
        ev_timer_start (loop, w);
        printf("2-----ev_now=%d,ev_time=%d\n",ev_now(EV_A),ev_time());
        printf("end\n");
}

int main (void)
{
        loop = EV_DEFAULT;
        int sock = socket(AF_INET,SOCK_DGRAM,0);
        if(sock<0){
                perror("socket");
                exit(1);
        }

        struct sockaddr_in local;
        local.sin_family = AF_INET;
        local.sin_port = htons(7777);
        local.sin_addr.s_addr = inet_addr("0.0.0.0");
        if(bind(sock,(struct sockaddr*)&local,sizeof(local))<0){
                perror("bind");
                exit(0);
        }

        ev_io_init (&stdin_watcher, udp_cb,sock, EV_READ);
        ev_io_start (loop, &stdin_watcher);

        ev_timer_init (&timeout_watcher, timeout_cb, 1,0.0);
        ev_timer_start(loop, &timeout_watcher);
        ev_run (loop, 0);

        return 0;
}

compile : gcc -o test 1.c -lev

test it and the result is : before the timeout happy and udp sock recived data in this period. this timeout_cb always trigger twice and quit. i cannot decide this is bug? Why it triggers twice instead of once?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.