使用SIGALARM为connect设置超时
2024-08-31 07:11:55
static void connect_alarm(int); int connect_timeo(int sockfd, const SA *saptr, socklen_t salen, int nsec)
{
Sigfunc *sigfunc;
int n; sigfunc = signal(SIGALRM, connect_alarm);
if (alarm(nsec) != )
err_msg("connect_timeo: alarm was already set"); if ( (n = connect(sockfd, saptr, salen)) < ) {
close(sockfd);
if (errno == EINTR)
errno = ETIMEDOUT;
}
alarm(); /* turn off the alarm */
signal(SIGALRM, sigfunc); /* restore previous signal handler */ return(n);
} static void connect_alarm(int signo)
{
return; /* just interrupt the connect() */
}
最新文章
- HashMap两种遍历方式的深入研究
- 【转】Caffe初试(四)数据层及参数
- Oracle的DML语言必备基础知识
- vconfig使用帮助
- 关于P,V操作理解的分析
- windows namedPipe 命名管道clent and server
- 论文阅读之 A Convex Optimization Framework for Active Learning
- 【CodeForces】【321E】Ciel and Gondolas
- 多个非同源的shared_ptr管理对象引起double free
- Flash设置全屏后,放到网页中显示不正常
- JAVA_SE复习(Class)
- Android Wear 数据类型和接口的发送和同步数据概述
- 【转】linux建立软链接
- c# 错误 两个输出文件名解析为同一个输出路径
- height:auto 火狐没边框
- oracle 12c centos 7 安装配置
- mybatis foreach报错It was either not specified and/or could not be found for the javaType Type handler
- [PHP]算法- 二叉树的深度的PHP实现
- 实现Qemu aarch32虚拟开发板ping www.baidu.com
- react 首页加载loading