C++网络简单的发送和接收
我正在尝试将 10 台计算机连接在一起,我想编写的程序将有一台“控制”计算机。根据我的查找,这台计算机将获取通过网络发送的所有数据包并对它们进行回显......对吗?其他计算机需要能够向“控制”发送信息(然后回显给其他计算机)...是否有一种简单!或简单的方法来做到这一点这?据我所知,我想要一个非阻塞套接字?
我研究过套接字等,但对于像我这样的业余程序员来说,这似乎是一项艰巨的任务:)
我有点寻找一个简单的类含义,它有一个 send()
和一个事件驱动的recv()
。
我不会通过网络发送那么多信息。
I'm trying to link 10 computers together, the program I would like to write would have one 'control' computer. From what I've looked up this computer would take all the packets sent over the network and do a echo with them... right? The other computers would need to be able to send information (then echoed to the others) to the 'control' ... is there a easy! or simple way to do this? From what I've seen I want a non-blocking socket?
I have looked into sockets and such but for an amateur programmer like me, this seems like a daunting task :)
I'm kind-of looking for an easy class implication that has a send()
and an event driven recv()
.
I'm not going to be sending that much information over the network.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://beej.us/guide/bgnet/
在我看来,这是无可争议的套接字编程最佳指南。
http://beej.us/guide/bgnet/
In my opinion the unchallenged best guide to socket programming.
通过网络进行的任何通信都需要您对网络有一些了解。即使是回显服务器也必须决定在单个线程中阻塞或在一定程度上提供多个线程。什么协议?目标空间是什么(传统互联网、隔离局域网等)?
W. Richards Stevens 写了关于该主题的好书(基于 UNIX)。 Beej 是另一个很好的在线资源。
如果您确实想要简单,为什么不直接使用 Ruby 或 Python 等脚本语言来完成此任务呢?
Any communications over a network requires you to have some understanding of networking in general. Even an echo server will have to decide to block in a single thread or provide multiple threads up to a point. What protocol? What is the target space (traditional Internet, isolated LAN, etc)?
W. Richards Stevens wrote good books on the subject (UNIX-based). Beej is another good online resource.
If you are really looking for easy why not just use a scripting language such as Ruby or Python to do this?