Boost.asio C + + Network programming translator (3)

Source: Internet
Author: User

Boost.asio Getting StartedWhat is Boost.asioto put it simply, Boost.asio is a cross-platform C + + library that is primarily used for networking and some other underlying input/output programming. There are many ways to design a computer network, but the Boost.asio way is far superior to them. It was included in boost in 2005 and then tested by a vast bosot of users and used in many projects, such as Remobo (http://www.remobo.com), which allows you to create your own instant private network (IPN), Libtorrent ( Http://www.rasterbar.com/products/libtorrent) A library that implements the Bitstream client, Pokerth (http://www.pokerth.net) a card game that supports LAN and Internet gaming. Boost.asio successfully abstracted the concept of input and output on network communications, COM serial ports, and files . You can program either synchronous or asynchronous input and output based on these. Read (stream, buffer [, extra options])
Async_read (stream, buffer [, extra options], handler)
Write (stream, buffer [, extra options])
Async_write (stream, buffer [, extra options], handler)
[?...]As you can see from the previous code snippet, these functions support a stream instance of an arbitrary content (not just a socket, which we can read and write to). as a cross-platform library, Boost.asio can be used on most operating systems. Can support up to thousands of concurrent connections at a time. Its The network section is inspired by the Berkeley Software distribution (BSD) socket, which provides a support for Transmission Control Protocol (TCP) sockets, User Datagram Protocol (UDP) Sockets and Internet Control Message Protocol (IMCP) sockets , and if necessary, you can extend them to support your own protocols. HistoryBoost.asio was developed in 2003 and then introduced in the 2005 version of the December Boost 1.35. The original author is Christopher M. Kohlhoff, you can contact him by [email protected]. This library is tested on the following platforms and compilers:32-bit and 64-bit Windows, using Visual C + + 7.1 and aboveusing MinGW under Windows Use Cygwin under windows (make sure you have defined __use_232_sockets)
Linux based on 2.4 and 2.6 cores, using g++ 3.3 and aboveuse g++ 3.3 and above under SolarisMAC OS X 10.4 or above using g++ 3.3 and above
It may be able to use more than sun Studio 11 under neutrino 6.3,solaris such as Aix 5.3,hp-ux 11i V3,QNX, True64 C + + under V5.1,windows Borland 5.9.2 above and above the platform to use. (Please contact www.boost.org for more details)DependentBoost.asio relies on the following libraries:Boost.system: This library provides operating system support for the Boost library (http://www.boost.org/doc/libs/1_51_0/doc/html/boost_system/index.html)
Boost.regex: Use the Boost::regex parameter when using this library (optional) so that you can reload Read_until () or Async_read_until (). boost.datetime: Use this library (optional ) so that you can use the timers in Boost.asio. OpenSSL: Use this library (optional ) so that you can use the SSL support provided by Boost.asio.
compiling Boost.asio Boost.asio is a library with only header files. However, depending on your compiler and the size of your program, you can choose to compile the Boost.asio in the same way as the source file. If you want to do this to reduce compilation time, there are several ways: in one of your source files, add # include <boost/asio/impl/src.hpp> (if you're using SSL, add #include <boost/ asio/ssl/impl/src.hpp>) in all of your source files, Add the # define Boost_asio_separate_compilation Note that Boost.asio relies on Boost.system and relies on boost.regex when necessary, so you need to compile boost with the following instructions : Bjam–with-system–with-regex stage
If you also want to compile tests at the same time, you need to use the following command:bjam–with-system–with-thread–with-date_time–with-regex–with-serialization StageThere are a lot of examples of this library, and you can look at it together with the examples in this book. Important MacrosIf there is a need to set up boost_asio_disable_threads, he will let the thread support in the Boost.asio fail, regardless of whether threading support is used during the build boost.

Boost.asio C + + Network programming translator (3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.