在LAN上通讯两个Windows应用程序. [英] Communication b/w two Windows applications on LAN.

查看:82
本文介绍了在LAN上通讯两个Windows应用程序.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个应用程序,其中在运行时创建了一些对象.

例如.我有一个表单,其中我在运行时创建了一些文本框,并为这些文本框分配了一些值.

我想将这些对象传递给局域网上另一台计算机上运行的同一应用程序.
我怎样才能做到这一点?我从未使用过Remoting,套接字编程等.
任何人都可以为我提供此示例或任何指导的简单示例吗?谢谢.

Hi,
I have created an application in which i created some objects on run time.

For eg. I have a form in which i created some text-box at run time and assign some values to these text-boxes.

I want to pass these objects to same application running on Other computer on LAN.
How can i do this? I have never used R emoting, Socket Programing etc.
Can anyone provide me a simple example for this or any guidance? Thanks.

推荐答案

是的,您可以创建此示例检查此示例
多线程客户端/服务器套接字类 [
Yes you can create this check this example
Multi-threaded Client/Server Socket Class[^]


您可以使用以下级别:低套接字级别使用System.Net.Sockets.Socket,使用System.Net.Sockets.UdpClient(UDP),System.Net.Sockets.TcpListener/System.Net.Sockets.TcpClient(TCP)、. NET远程处理,WCF(是否自托管)的套接字级别要高一些.
较低的级别将需要封送处理和/或序列化;您可能还需要知道如何创建和使用DataContract和/或ServiceContract,尤其是对于WCF.线程和线程同步是最重要的方面之一.

我建议您不要尝试在应用程序之间进行通信(尽管这取决于您的目标).在服务(不一定是客户端服务器)和客户端方面进行思考通常会更有效率.

即使在每个级别上都编写最基本的示例,也可能会写出非常大的文章,可能……难以估计……数十页.谁来为您编写?最好尝试在CodeProject中查找单独主题的文章,并使用每种技术创建原型应用程序.只有这样,您才能感觉到它们足以决定应用程序上的设计.

基本建议:不要像某些人一样发送UI控件之类的东西.创建纯数据类型并发送纯数据;在数据和UI之间创建松散耦合,将UI与数据模型,通用功能和特定于应用程序的功能隔离.

—SA
You can use the following levels: low sockets level using System.Net.Sockets.Socket, a little higher socket levels using System.Net.Sockets.UdpClient (UDP), System.Net.Sockets.TcpListener/System.Net.Sockets.TcpClient (TCP), .NET remoting, WCF (self-hosted or not).

Lower levels will need Marshaling and/or Serialization; you may also need to know how to create and use DataContract and/or ServiceContract, especially with WCF. One of the most essential aspects will be threading and thread synchronization.

I would suggest you don''t try to communicate between applications (it depends on your goal though). It''s usually more productive to think in terms of service (not necessarily client-server) and clients.

Making even most elementary examples on every level would make a really big article, may be… hard to estimate… some tens of pages. Who will write it for you? Better try to find articles of separate topic in CodeProject and create prototype applications using each technique. Only in this way you will be able to feel them well enough to decide on designs on your applications.

Basic advice: don''t try to send UI controls and the like, like some do. Create pure-data types and send pure data; create loose coupling between data and UI, isolate UI from data model, universal functionality and application-specific functionality.

—SA


这篇关于在LAN上通讯两个Windows应用程序.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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