Tcp Client two way communication help

若如初见. 提交于 2019-12-09 07:19:55

问题


I want to communicate between two applications or winforms in C# using clients and server its like i want a server continiously listening to incoming messages from a client or clients and when the msg is received i want to reply back to the client that sent the information for processing can any one help with code example


回答1:


Sounds like a good case for WCF using netTcpBinding in an intranet environment! :-)

Check out these intros to WCF:

  • Getting started with WCF
  • WCF Templates and Tools
  • WCF Developer Center
  • WCF Getting Started - Videos, Screencasts, Whitepapers

There's an especially good series of screencasts with Aaron Skonnard (also available from the WCF Getting Started section) which explains step by step and in easy portions how to get up and running with your first adventures in WCF! :-)

Also, WCF does offer specific support for peer-to-peer networking, e.g. discovery and establishing communications between sibling nodes - see some articles on that topic here:

  • Peer-to-Peer Programming with WCF
  • Building a really simple WCF P2P application
  • Peer-to-peer using WCF's netPeerTcpBinding
  • Connect Smart Client Applications with WCF (PDF)

Compared to a "hand-crafted" solution based on sockets, WCF gives you a lot of ready-made plumbing code which you don't have to worry about - security, reliability, message encryption, transaction support, and much more. Why do that all yourself, if you can just use it ready-made?

Marc




回答2:


C# TCP-IP client server example:

http://www.codeproject.com/KB/IP/tcpclientserver.aspx



来源:https://stackoverflow.com/questions/1354348/tcp-client-two-way-communication-help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!