Article Directory
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 ip
in the code .socket
Therefore, this article encapsulates a cross-platform function to obtain all ip
addresses 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>
#