首页 > 技术文章 > libevent cs

xpylovely 2019-07-11 22:21 原文

int evutil_make_listen_socket_reuseable(evutil_socket_t sock);

相当于执行以下操作

int one = 1;

setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one,(ev_socklen_t)sizeof(one));

------------------------------------------------------------------------------

 int evutil_make_socket_nonblocking(evutil_socket_t fd);

相当于执行以下操作

int flags;
flags = fcntl(fd, F_GETFL, NULL);
flags & O_NONBLOCK;
fcntl(fd, F_SETFL, flags | O_NONBLOCK)  ;
---------------------------------------------------------------------------------

 1.event_new();间接调用event_assign();

#include <sys/time.h>

void timeradd(struct timeval *a, struct timeval *b,
struct timeval *res);

void timersub(struct timeval *a, struct timeval *b,
struct timeval *res);

void timerclear(struct timeval *tvp);

int timerisset(struct timeval *tvp);

int timercmp(struct timeval *a, struct timeval *b, CMP);

推荐阅读