如何在 C 中获取活动网络接口的列表? [英] How to get a list of active network interfaces in C?

查看:36
本文介绍了如何在 C 中获取活动网络接口的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 C 获取系统中的活动接口列表?我需要使用什么 API 或库?我可以选择一个特定的接口来在套接字编程中发送数据吗?如果是,请举例说明.

解决方案

如果在 Linux 上你可能想看看:

int getifaddrs(struct ifaddrs **ifap);

<块引用>

getifaddrs() 函数创建一个描述本地系统网络接口的结构链表,并存储第一项的地址*ifap 中的列表.

How to get the list of active interface in a system using C? what API or library i need to use? and Can i choose a particular interface to send data in socket programming? if yes then please give an example.

解决方案

If on Linux you might like to take look at:

int getifaddrs(struct ifaddrs **ifap);

The getifaddrs() function creates a linked list of structures describing the network interfaces of the local system, and stores the address of the first item of the list in *ifap.

这篇关于如何在 C 中获取活动网络接口的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆