需要 C# 简单 DataSocket 示例
我是 C# Socket 编程新手。我正在尝试构建一个简单的应用程序,可以检测客户端应用程序何时连接到服务器应用程序。 连接后,我想向服务器发送 1 条信息并收到 1 个响应(确认)。 之后,我只想知道连接何时断开。在我的应用程序中,我不必立即知道连接何时断开,只要在超时内(如果可以的话)即可。
有人可以帮助我了解我需要做什么才能实现这一目标。示例源代码会很好,我也是一名新手程序员,这个主题超出了我的想象。 我需要有关客户端应用程序和服务器应用程序的帮助。
提前致谢!
乔雷尔
I am new to C# Socket programming. I am trying to build a simplistic application that can detect when a client application connects to the server application.
When connected, I want to send 1 piece of information to the server and receive 1 response back (confirmation).
Afterwards, I just want to know when the connection is broke. Within my application, I do not have to know instantly when the connection is broken, just within the timeout if fine.
Can someone please help me understand what I need to do to accomplish this. Sample source code would be nice, again I am a novice programmer and this topic is way above my head.
I would need help with the client app and server app.
Thanks in advance!
Jorel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我是一个新手程序员,我不会从套接字开始。这不是一个容易开始的主题,您需要了解的不仅仅是如何发送一条信息。您还需要了解协议如何工作以及如何处理它们发送/接收信息的方式。
我建议您改用 wcf,因为 WCF 会为您处理所有较低级别的详细信息。您只需要知道如何发送和接收信息。
I would not begin with sockets if I were a novice programmer. It's not an easy subject to start with, and you need to know more than just how to send a piece of information. You need to know how the protocols work too and how do deal with their way of send/receiving information.
I would recommend you to use wcf instead, since WCF takes care of all lower level details for you. You will just need to know how to send and receive information.