gpt4 book ai didi

c++ - 在 C++ 中转换 IP 地址的问题

转载 作者:行者123 更新时间:2023-11-30 03:08:51 26 4
gpt4 key购买 nike

我需要在我的代码中找到我的节点的 IP 地址。目前,我有这一行:这一行:

IPv4Address addr = nb_ipv4->GetAddress (maininterface , 0);

在这一行中,我希望获得我的主界面的 IP 地址,但我却看到了这个错误:

error:conversion from 'ns3::Ipv4InterfaceAddress' to non-scalar type 'ns3::Ipv4Address' 

谁能帮我解决这个错误?

最佳答案

我认为必须将其标记为 C++,并且(如果它是 The ns-3 network simulator)您必须这样做:

IPv4Address addr = nb_ipv4->GetAddress(maininterface).GetLocal();

关于c++ - 在 C++ 中转换 IP 地址的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4543675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com