第九章 Helper functions and types for Libevent
来源:互联网 发布:unity3d游戏案例 编辑:程序博客网 时间:2024/06/05 19:50
Helper functions and types for Libevent
头文件
9.1 基本类型
9.1.1 evutil_socket_t
除了在windows中,大部分系统中socket是一个int。在windows中socket是一个SOCKET类型。
#ifdef WIN32 #define evutil_socket_t intptr_t#else #define evutil_socket_t int#endif
9.1.2 标准整数类型
和C99一样,每个类型都精确的bit width。
9.2 跨平台的定时器函数
#define evutil_timeradd(tvp,uvp,vvp) #define evutil_timersub(tvp,uvp,vvp)//这两个宏加或减前两个参数,结果存在第三个参数中。#define evutil_timerclear(tvp)#define evutil_timerisset(tvp)//清除tvp使其值为0.int evutil_gettimeofday(struct timeval *tv,struct timezone *tz);//tv反回当前时间,tz未使用。
9.3 可移植socket API
int evutil_closesocket(evutil_socket_t s);#define EVUTIL_CLOSESOCKET(s) evutil_closesocket(s)//关闭一个socket。在UNIX中,它是close()的别名;在windows中,它调用closesocket()。
#define EVUTIL_SOCKET_ERROR()#define EVUTIL_SET_SOCKET_ERROR(errcode)#define evutil_socket_geterror(sock)#define evutil_socket_error_to_string(errcode)//获取和操作socket错误码。//EVUTIL_SOCKET_ERROR()返回从这个线程最后的socket操作的全局错误码。
int evutil_make_socket_nonblocking(evutil_socket_t sock);//将sock文件描述符设为非阻塞模式int evutil_make_listen_socket_reuseable(evutil_socket_t sock);//类似于UNIX中的SO_REUSEADDR。当监听套接字关闭后,其他套接字可以立刻合用其socket地址。
int evutil_make_socket_closeonexec(evutil_socket_t sock);//当调用exec()函数时,关闭sock。在UNIX上设置了FD_CLOEXECint evutil_socketpair(int family,int type,int protocol,evutil_socket_t sv[2]);//与UNIX中socketpair()行为相同。它生成两个相互联接的socket。
9.4 可移植的这串符操作函数
0 0
- 第九章 Helper functions and types for Libevent
- FSDMGR Helper Functions for FSD Developers
- 6.3Return Types and the return Statement &6.5Overloaded functions
- IP Helper Functions
- Shapes and line types for R
- MATLAB and Octave Functions for Computer Vision
- libevent for linux building and installation
- libevent for echo server and client
- libevent for linux building and installation
- libevent for echo server and client
- 第六章: types and declarations
- 第二十~章 Functions and Generators
- MATLAB and Octave Functions for Computer Vision and Image Processing
- Professional SQL Server 2005 CLR Programming: with Stored Procedures, Functions, Triggers, Aggregates and Types
- Return types of virtual functions
- No way to generate HTML markup with data-link and helper functions in JsViews like in JsRender
- MATLAB Functions for Computer Vision and Image Analysis
- [Javascript] Some very simple functions for Word and Excel handling
- 安卓动画之listView动画,Activity切换动画,Fragment切换动画及LayoutAnimation的使用
- hdu 5612Baby Ming and Matrix games(dfs)
- 第八章 working with events
- Linux设备模型之input子系统详解(一)
- Apache服务器-使用.htaccess实现图片防盗链方法
- 第九章 Helper functions and types for Libevent
- JS——Sublime Text2怎么快速的新建一个HTML的头部
- iOS9模拟器无法进行HTTP网络请求的解决方案
- 第十章 Bufferents
- POJ2155 Matrix
- LibGDX教程——重建Flappy Bird——(7) 添加GUI信息
- greenDAO
- 泛型入门(一)
- Linux设备模型之input子系统详解(二)