如何在C#.Net中通过Tcp/Ip广播数据 [英] How to broadcast a data over Tcp/Ip in C#.Net

查看:327
本文介绍了如何在C#.Net中通过Tcp/Ip广播数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我有一个问题要和你们分享.

情况如下:

我有2个受 pic (微控制器单元)控制的设备.我的计算机和这2个设备在网络中相互连接.我可以从计算机ping这些设备,这没有问题.

我想问的是如何向他们广播数据?因此,我可以测试信号目的地时间btw的差异.他们.

任何建议将不胜感激.
最好的问候..

Hey everyone.

I have a problem to share you with you guys.

Here is the situation:

I have 2 devices which are being controlled by pic (micro controller units). My computer and these 2 devices are connected to each other in a network. I can ping from my computer to these devices, there is no problem with that.

What I want to ask is how to broadcast a data to them? So, I can test the difference of signal destination time btw. them.

Any suggestions will be well appreciated.
My best regards..

推荐答案

如果要使用TCP连接,则不会广播. TCP [ UDP [
If you want to use TCP connection, then there is NO broadcast. TCP[^] is a point to point protocol.
Check out UDP[^].


要将数据发送到网络设备,可以使用TcpClient类.

为了使发送和接收正常工作,您必须了解这些设备的通信协议,即数据包结构,握手等.

我建议找到这些设备的手册,并了解它们之间的通信方式.
To send data to a network device you can use the TcpClient class.

For this sending and receiving to work you must know the communication protocol of those devices, ie packet structure, handshaking etc.

I suggest finding the manuals for those devices and seeing how they communicate.


我对此并不十分确定,但可以尝试使用广播地址".

假设您的开发PC具有IP 192.168.128.1/24.整个子网的地址为192.168.128.0/24.
192.168.128.255的ping操作应使每个设备都在同一子网中进行响应.
I am not 100% sure about that, but try a "broadcast address".

Let''s assume your development PC to have IP 192.168.128.1/24. The address of the whole subnetwork would be 192.168.128.0/24.
A ping to 192.168.128.255 should make every device respond that is in the same subnetwork.


这篇关于如何在C#.Net中通过Tcp/Ip广播数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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