当前位置:网站首页>socket的connect函数用法
socket的connect函数用法
2022-06-22 18:33:00 【涛歌依旧】
看源码,看到这样一段代码:
static int connSocketConnect(connection *conn, const char *addr, int port, const char *src_addr,
ConnectionCallbackFunc connect_handler) {
int fd = anetTcpNonBlockBestEffortBindConnect(NULL,addr,port,src_addr);
if (fd == -1) {
conn->state = CONN_STATE_ERROR;
conn->last_errno = errno;
return C_ERR;
}
conn->fd = fd;
conn->state = CONN_STATE_CONNECTING;
conn->conn_handler = connect_handler;
aeCreateFileEvent(server.el, conn->fd, AE_WRITABLE,
conn->type->ae_handler, conn);
return C_OK;
}
在实现超时connect时候,经常可以这么多,需要set nonblock socket
边栏推荐
- 1.4-----PCB设计?(电路设计)确定方案
- [nfs failed to mount problem] mount nfs: access denied by server while mounting localhost:/data/dev/mysql
- 08_一句话让你人间清醒
- [in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
- 商业智能BI数据仓库中的指标、维度和模型到底是什么?
- 小甲鱼老师《带你学C带你飞》的后续课程补充
- [deeply understand tcapulusdb technology] cluster management operation
- 修改隐含参数造成SQL性能下降案例之一
- 使用 qrcodejs2 生成二维码详细API和参数
- Assign values to objects
猜你喜欢

Nrf51822 peripheral learning

1.4----- PCB design? (circuit design) determination scheme

Openpnp debugging ------ 0816 Feida Tui 0402 taping

0.0 - Solidworks如何才能卸载干净?

数字经济加速落地,能为中小企业带来什么?

matplotlib设置坐标轴刻度间隔

2. what is mechanical design?

Nlp-d57-nlp competition D26 & skimming questions D13 & reading papers & finding bugs for more than an hour

图的存储结构(邻接矩阵)

51万奖池邀你参战!第二届阿里云ECS CloudBuild开发者大赛来袭
随机推荐
2.什么是机械设计?
Huffman tree (C language)
[nfs failed to mount problem] mount nfs: access denied by server while mounting localhost:/data/dev/mysql
美图稳定性和运维保障方案
推荐一个解剖学网站
树和森林的遍历
51万奖池邀你参战!第二届阿里云ECS CloudBuild开发者大赛来袭
Recommend an anatomy website
【深入理解TcaplusDB技术】TcaplusDB新增机型
小甲鱼老师《带你学C带你飞》的后续课程补充
Xintang nuc980 usage record: basic description of development environment preparation and compilation configuration
第一篇 热身--隐式类型转换还是其他?
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc
生产系统SQL执行计划突然变差怎么办?
一文带你读懂内存泄露
二叉排序树的查找、插入和删除
About Random Forest
.Net 5.0 通过IdentityServer4实现单点登录之oidc认证部分源码解析
第六章 操作位和位串(二)
Matlab calling API