获取设备列表局域网用C [英] Get list of devices on LAN in C

查看:256
本文介绍了获取设备列表局域网用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得可用的设备(其IP地址或主机名应罚款)连接到我的本地网络的列表。我有在C#中的一些例子,但我无法找到使用C / C ++的样本。我熟悉BSD套接字API,只是为了澄清。

I'd like to get a list of available devices (their IP address or hostname should be fine) connected to my local network. I've got some examples in C#, but I couldn't find any sample using C/C++. I'm familiar with the BSD socket API, just to clarify.

我有一个存根一种理念:也许我应该确定IP地址范围,我的LAN上的设备有可能属于,然后确定它们是否如G。回应PING,或者类似的东西。我怎么能做到这些?

I have a "stub" kind of idea: maybe I should determine the range of the IP addresses that the devices on my LAN can potentially belong to, and then determine if they e. g. respond to PING, or something like that. How could I achieve these?

我想我的应用程序在Linux和iOS上运行。这就是为什么我会preFER BSD插座,或者在最大,基金会/ GNUstep的(尽管它们是用Objective-C)。

I want my application to run on Linux and iOS. That's why I'd prefer BSD sockets, or at a maximum, Foundation/GNUstep (although they are written in Objective-C).

推荐答案

您也可以如发送一个ICMP回应请求数据包发送到224.0.0.1。这是一个特殊的所有节点多播地址的每个节点应(除非防火墙规则或网络策略设置prevents它)。

You can also e.g. send an ICMP echo request packet to 224.0.0.1. This is a special all-nodes multicast address every node should respond to (except if a firewall rule or network policy setting prevents it).

这篇关于获取设备列表局域网用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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