开发者

C++ Builder - basic internet programming

I want to connect two PCs and have them communicate. Is there a nice component to do that? (preferably from TMS, or free), or do I just use standard C++ socket libraries?

What about sending data? Should I invent a simple protocol? TLV (type/length/value), where T is the message type and .. you get the pictur开发者_如何学运维e...


Since you are using C++ Builder, you should really be using the Indy components, they are a nice well tested and easy to work with set of networking components... And they are already built into C++ Builder. If you are using C++ Builder, using Qt or boost can be really problematic (of course depending on C++ Builder version).

Indy components: http://www.indyproject.org/index.en.aspx

With Indy components you get all the components you need for basically every sort of network development you need, it is by far the most complete networking solution for C++Builder/Delphi that I have seen.

You might find this article interesting: Developing TCP/IP-based Server Applications using Indy Components [1] it shows examples in Delphi, but converting to C++ should be trivial.

Besides the Delphi in Depth [2] book is a good resource and contains samples in C++ as well.

About the developing your own protocol, it is almost impossible to answer that question with a definitive answer, it really depends on the requirements you have. Perhaps you should start by asking, is there an existing protocol that would work for me, before you end up, perhaps, reinventing the wheel.

[1] http://conferences.embarcadero.com/article/33256
[2] http://www.atozed.com/indy/book/index.en.aspx


You should look at Qt or Boost. (I personally prefer Qt's network API and documentation, but you may feel differently.)

And for something simple, why would you invent your own protocol? Just use HTTP. It's easy to work with and you can use all kinds of tools, not just your own code, to verify that everything is working properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜