c++ Obtain ip through domain name (cross-platform)


foreword

Click to view the catalog of this set of teaching materials: C/C++ tutorial catalog

In normal network programming, we often need to obtain a certain domain name ip, such as Baidu's domain name is www.baidu,com, but we don't know its address, and we can't use it to connect ipin the code .socket

Therefore, this article encapsulates a cross-platform function to obtain all ipaddresses of the corresponding domain name, which is convenient for everyone to use

1. The final effect

First demonstrate the effect of encapsulation:

code:

#include<iostream>
#

Guess you like

Origin blog.csdn.net/weixin_50964512/article/details/130943711