Boost Asio Examples(整理)

Allocation

This example shows how to customise the allocation of memory associated with asynchronous operations.

Buffers

Chat

This example implements a chat server and client. The programs use a custom protocol with a fixed length message header and variable length message body.

The following POSIX-specific chat client demonstrates how to use the posix::stream_descriptor class to perform console input and output.

Echo

A collection of simple clients and servers, showing the use of both synchronous and asynchronous operations.

HTTP Client

Example programs implementing simple HTTP 1.0 clients. These examples show how to use the read_until and async_read_until functions.

HTTP Server

This example illustrates the use of asio in a simple single-threaded server implementation of HTTP 1.0. It demonstrates how to perform a clean shutdown by cancelling all outstanding asynchronous operations.

  • boost_asio/example/http/server/connection.cpp
  • boost_asio/example/http/server/connection.hpp
  • boost_asio/example/http/server/connection_manager.cpp
  • boost_asio/example/http/server/connection_manager.hpp
  • boost_asio/example/http/server/header.hpp
  • boost_asio/example/http/server/mime_types.cpp
  • boost_asio/example/http/server/mime_types.hpp
  • boost_asio/example/http/server/posix_main.cpp
  • boost_asio/example/http/server/reply.cpp
  • boost_asio/example/http/server/reply.hpp
  • boost_asio/example/http/server/request.hpp
  • boost_asio/example/http/server/request_handler.cpp
  • boost_asio/example/http/server/request_handler.hpp
  • boost_asio/example/http/server/request_parser.cpp
  • boost_asio/example/http/server/request_parser.hpp
  • boost_asio/example/http/server/server.cpp
  • boost_asio/example/http/server/server.hpp
  • boost_asio/example/http/server/win_main.cpp

HTTP Server 2

An HTTP server using an io_service-per-CPU design.

HTTP Server 3

An HTTP server using a single io_service and a thread pool calling io_service::run().

HTTP Server 4

A single-threaded HTTP server implemented using stackless coroutines.

ICMP

This example shows how to use raw sockets with ICMP to ping a remote host.

  • boost_asio/example/icmp/ping.cpp
  • boost_asio/example/icmp/ipv4_header.hpp
  • boost_asio/example/icmp/icmp_header.hpp

Invocation

This example shows how to customise handler invocation. Completion handlers are added to a priority queue rather than executed immediately.

  • boost_asio/example/invocation/prioritised_handlers.cpp

Iostreams

Two examples showing how to use ip::tcp::iostream.

  • boost_asio/example/iostreams/daytime_client.cpp
  • boost_asio/example/iostreams/daytime_server.cpp

Multicast

An example showing the use of multicast to transmit packets to a group of subscribers.

  • boost_asio/example/multicast/receiver.cpp
  • boost_asio/example/multicast/sender.cpp

Serialization

This example shows how Boost.Serialization can be used with asio to encode and decode structures for transmission over a socket.

  • boost_asio/example/serialization/client.cpp
  • boost_asio/example/serialization/connection.hpp
  • boost_asio/example/serialization/server.cpp
  • boost_asio/example/serialization/stock.hpp

Services

This example demonstrates how to integrate custom functionality (in this case, for logging) into asio’s io_service, and how to use a custom service with basic_stream_socket<>.

  • boost_asio/example/services/basic_logger.hpp
  • boost_asio/example/services/daytime_client.cpp
  • boost_asio/example/services/logger.hpp
  • boost_asio/example/services/logger_service.cpp
  • boost_asio/example/services/logger_service.hpp
  • boost_asio/example/services/stream_socket_service.hpp

SOCKS 4

Example client program implementing the SOCKS 4 protocol for communication via a proxy.

  • boost_asio/example/socks4/sync_client.cpp
  • boost_asio/example/socks4/socks4.hpp

SSL

Example client and server programs showing the use of the ssl::stream<> template with asynchronous operations.

Timeouts

A collection of examples showing how to cancel long running asynchronous operations after a period of time.

Timers

Examples showing how to customise deadline_timer using different time types.

Porthopper

Example illustrating mixed synchronous and asynchronous operations, and how to use Boost.Lambda with Boost.Asio.

Nonblocking

Example demonstrating reactor-style operations for integrating a third-party library that wants to perform the I/O operations itself.

  • boost_asio/example/nonblocking/third_party_lib.cpp

UNIX Domain Sockets

Examples showing how to use UNIX domain (local) sockets.

  • boost_asio/example/local/connect_pair.cpp
  • boost_asio/example/local/stream_server.cpp
  • boost_asio/example/local/stream_client.cpp

Windows

An example showing how to use the Windows-specific function TransmitFile with Boost.Asio.

  • boost_asio/example/windows/transmit_file.cpp
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值