当前位置:网站首页>ipv6相关
ipv6相关
2022-04-22 13:59:00 【qq_23953675】
Address already in use
当同时监听某个端口的IPv4和IPv6时,运行bind函数将执行失败,提示“bind : Address already in use”。
原因:ipv6的socket默认情况下也会接收ipv4的报文,不同的socket不能监听同IP 下的同端口
方法:设置ipv6的socket只接收ipv6地址的报文
int on = 1;
if(0 > setsockopt(fd_v6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)))
{
perror("setsockopt");
return -1;
}
IPv6相关
- fe80 本地链路IPv6 地址,只用于本地使用,不能用于往外通信
- 访问ipv6的web服务器http://[fe80::aa:bb:cc:dd],带有中括号的访问
- ping IPv6,如果是fe80开头的,则ping6 fe80::aa:bb:cc:dd%xx,添加%后面加网卡名
- ping IPv6,如果非fe80开头的,则ping6 fe80::aa:bb:cc:dd即可
- 使用boost添加网络链接时,IPv6也应该是fe80::aa:bb:cc:dd%xx才可
如何使用boost的asio实现同时监听IPv4和IPv6
boost::asio::io_service io_serv;
boost::asio::ip::tcp::acceotpr acceotor_v4(io_serv);
boost::asio::ip::tcp::acceotpr acceotor_v6(io_serv);
acceotor_v4.open(ip::tcp::v4());
acceotor_v6.open(ip::tcp::v6());
设置属性
//设置IPv6仅接收IPv6地址
setsockopt(fd_v6, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on);
无地址绑定
//绑定IPv4
acceotor_v4.bind(ip::tcp::endpoint(ip::tcp::v4(), port));
//绑定IPv6
acceotor_v6.bind(ip::tcp::endpoint(ip::tcp::v6(), port));
有地址绑定
boost::asio::ip::address addr = boost::asio::ip::address::from_string(ip);
acceotor_v4.bind(ip::tcp::endpoint(addr, port));
版权声明
本文为[qq_23953675]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_23953675/article/details/124093450
边栏推荐
- 实现全链路重塑!从思维走向实践,数字化转型 IT 经营的成功路径
- Socket的阻塞模式和非阻塞模式
- Detailed explanation of heap sorting (C language)
- Imeta: integrating macroomics to re understand life and Environmental Sciences
- 2022焊工(初级)考试试题及答案
- Osgearth configuring Map Resources
- 奥雅DAO社区质押挖矿dapp系统定制
- io_ Application of ring technology in distributed cloud native database
- Chapitre sur la promotion précise des investissements dans la gestion de l'exploitation numérique des parcs industriels
- Leetcode-3 longest substring without duplicate characters
猜你喜欢
![uniapp转微信开发者工具报错 - [ app.json 文件内容错误] app.json: 未找到 [“sitemapLocation“] 对应的 sitemap.json 文件](/img/3b/2f371eab7d2f9e976dcd4612a19518.png)
uniapp转微信开发者工具报错 - [ app.json 文件内容错误] app.json: 未找到 [“sitemapLocation“] 对应的 sitemap.json 文件

Good collection (1)

SixTool多功能多合一代挂助手系统源码

Thoughts on dealing with high concurrency problems

樹莓派開發筆記(十二):入手研華ADVANTECH工控樹莓派UNO-220套件(一):介紹和運行系統

Genesis创意漫画之【稳定通证】

Genesis公链赋予DAO全新生命力

產業園區數字化運營管理之“精准招商”篇

Redis(六)-Redis的常用数据类型之Set集合

机器越“智能”,数据标注员越容易被淘汰?丨曼孚科技
随机推荐
Chapitre sur la promotion précise des investissements dans la gestion de l'exploitation numérique des parcs industriels
CDF全球调查:软件交付性能停滞不前
Yyds dry goods inventory solving sword finger offer: motion range of robot
苏小红C语言程序设计第四、五章知识总结
makefile 调用bash脚本遇到的坑
eBPF学习 - 入门
2022年 MathorCup 思路分享
跌吧,继续跌吧,小灰的基金已亏损64万。。。
2022焊工(初级)考试试题及答案
七年谋“一剑”,站在边缘云的风口,如何加速企业数字化转型?
数据库表空间损坏,备份表数据异常如何处理?
【计量经济学】统计推断
Brief analysis of Apache skywalking alarm dynamic configuration source code
Osgearth configuring Map Resources
上午在改BUG,下午就通知被裁了
The more "intelligent" the machine is, the easier it is for data taggers to be eliminated? Manfu Technology
[finally waiting for you] wechat voice forwarding method - voice message forwarding
Ebpf learning - getting started
【Zeekr_Tech】ROS/ROS 2介绍
osgEarth配置地图资源