带超时IO函数封装, LIB-ZC

LIB-ZC 封装了常见的带超时IO函数

超时等待可读写

int ztimed_read_write_wait(int fd, int read_write_wait_timeout, int *readable, int *writeable);
int ztimed_read_write_wait_millisecond(int fd, long read_write_wait_timeout, int *readable, int *writeable);

返回 0: 不可读写, 1: 可读写或 socket 异常
可读: 则 *readable 赋值为 1; 可写: *writeable 赋值为 1

int ztimed_read_wait_millisecond(int fd, long read_wait_timeout);
int ztimed_read_wait(int fd, int read_wait_timeout);

返回 0: 不可读, 1: 可读或 socket 异常

int ztimed_write_wait_millisecond(int fd, long write_wait_timeout);
int ztimed_write_wait(int fd, int write_wait_timeout);

返回 0: 不可写, 1: 可写或 socket 异常

带超时读写

int ztimed_read(int fd, void *buf, int size, int read_wait_timeout);

返回 -1: 错误或超时; 0: socket关闭; >0: 读取字节数

int ztimed_write(int fd, const void *buf, int size, int write_wait_timeout);

返回 -1: 错误或超时; >0: 成功写的字节数

京ICP备18054515号-2 eli960@qq.com qq: 1537212398