当我们将消息发送到该机器时,如何在其他机器上弹出我们的应用程序窗口?
问题描述:
当我们将消息发送到该计算机时,如何在其他计算机上弹出我们的应用程序窗口?机器在同一个LAN网络上。
How to popup our application window on the other machines display when we send the message to that machine? Machines are on same LAN network.
答
你不能。
唯一的办法类似的事情是,如果程序在另一台机器上运行以接收消息并知道如何处理它,比如在窗口中显示它。
You can't.
The only way to do something like that is if a program is running on the other machine to receive the message and know what to do with it, like displaying it in a window.
你会想要使用System.Net.Sockets命名空间, http:// msdn。 microsoft.com/en-us/library/system.net.sockets(v=vs.110).aspx [ ^ ]
例如,它有一个UdpClient类, http://msdn.microsoft.com/en-us/library/system。 net.sockets.udpclient.aspx [ ^ ],你可以用来通过局域网进行通信。
你的代码将使用套接字绑定到某个端口(你可以选择任何未使用的端口) )。然后你可以使用计时器检查端口何时接收数据并相应地处理它。
我建议搜索本网站上的文章以及谷歌搜索c#。网络套接字示例。
You'll want to use the System.Net.Sockets namespace, http://msdn.microsoft.com/en-us/library/system.net.sockets(v=vs.110).aspx[^]
For example, it has a UdpClient class, http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx[^], which you can use to communicate over the LAN.
Your code will use the socket to bind to a certain port (you can pick anyone that is not in use). Then you can use a timer to check when the port receives data and process it accordingly.
I would suggest searching the articles on this site as well as google for c# .net sockets examples.