在vc ++中使用mac地址编程的套接字 [英] Socket programming using mac address in vc++

查看:226
本文介绍了在vc ++中使用mac地址编程的套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是套接字编程的新手,我想使用mac地址与控制器连接(因为控制器没有自己的IP地址),所以请在vc ++中发送参考示例mfc(windows)

在此先感谢.. !!!



我尝试过:



我是套接字编程的新手,我想使用mac地址与控制器连接(因为控制器没有自己的IP地址),所以请在vc ++中发送参考示例mfc(windows)

先谢谢.. !!!

I am new to socket programming, i want to interface with controller using mac address(since controller does not have its own IP address), so please send a reference example in vc++ mfc(windows)
Thanks in Advance..!!!

What I have tried:

I am new to socket programming, i want to interface with controller using mac address(since controller does not have its own IP address), so please send a reference example in vc++ mfc(windows)
Thanks in Advance..!!!

推荐答案

正如 Richard 所指出的那样,如果你想进行套接字编程那么你必须要使用 IP 地址(或主机名,无论如何,您不必担心分配给您自己的以太网卡的 IP 地址)。要开始使用套接字编程,您必须阅读f#*?+°(精彩)文档: Winsock入门(Windows) [ ^ ]。
As Richard pointed out, if you want to do socket programming then you have to use IP addresses (or hostnames, and anyway, you haven't to worry about the IP address assigned to your own ethernet card). In order to start with socket programming you have to read the f#*?+° (fantastic) documentation: Getting Started with Winsock (Windows)[^].


你显然不知道MAC地址是什么或它是什么用于。



您不能使用MAC地址与应用程序中的设备通信。它是一个硬件地址,用于唯一标识物理网段上的设备,并确保物理信号到达线路上的正确设备。它位于网络层(传输协议,如TCP / IP,IPX,AppleTalk ......)和物理层(将数据放在线路上并解码信号)。



想要这样做(使用带有MAC地址的套接字)是不可能的。使用Socket编程的通信在OSI模型中并没有那么远。



设备必须有一些其他的寻址方案(无论是TCP / IP,IPX,因为任何应用程序级通信库都不能使用MAC地址。请查阅设备上的文档以了解它是什么。
You obviously have no idea what a MAC address is or what it's used for.

You can NOT use a MAC address to talk to a device from your application. It is a hardware address used to uniquely identify a device on a physical network segment and ensure a physical signal gets to the correct device on the "wire". It sits between the network layer (transmission protocols like TCP/IP, IPX, AppleTalk, ...) and the physical layer (putting data on "the wire" and decoding the signals from it.)

Want you want to do (use sockets with MAC addresses) is not possible. Communication using Socket programming does not go down that far in the OSI model.

The device MUST have some other addressing scheme on it (be it TCP/IP, IPX, or whatever) because a MAC address can not be used by any application level communication library. Consult the documentation on the device to find out what that is.


您可以使用原始套接字编程使用以太网协议在低级别交换数据包。

以太网使用每个通信卡唯一的二进制地址,该通信卡由6个名为MAC的八位字节组成,这是媒体访问控制地址的缩写,是在IEEE-802网络下唯一标识网络的每个节点的硬件地址(MAC OSI数据链路控制(DLC)层的子层)。

由于可以拦截和/或修改comm数据包,因此限制使用原始套接字。出于这个原因,在linux下,原始套接字仅允许作为超级用户(root),并且在Windows下,自XP-SP2起禁用原始套接字。要使用它们,您需要一个特殊的驱动程序代码,如 winpcap [ ^ ]。

只需谷歌搜索以太网通讯或原始套接字,你就会找到一些信息。

只有2个站点:

使用winsock的Windows上的原始套接字编程 [ ^ ]和 RAW以太网 [ ^ ]
You can use raw socket programming to exchange packets on low level using Ethernet protocol.
Ethernet use a binary address unique for each comm card made of 6 octects named MAC, that is the short for Media Access Control address, a hardware address that uniquely identifies each node of a network under IEEE-802 networks (MAC sublayer of OSI Data Link Control (DLC) layer).
Use of raw socket is restricted because of the possibility to intercept and/or modify comm packets. For this reason under linux raw sockets are allowed only as superuser (root), and under Windows raw sockets are disabled since XP-SP2. To use them you need a special driver code like winpcap[^].
Just google for around for ethernet comm or raw sockets and you'll find some info.
Just 2 sites:
Raw socket programming on windows with winsock[^] and RAW ethernet[^]


这篇关于在vc ++中使用mac地址编程的套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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