├── .gitignore
├── COPYING
├── QAsioSocket.pri
├── QAsioSocket.pro
├── README.md
├── include
├── qasiosocket.h
├── qasiosslserver.h
├── qasiosslsocket.h
├── qasiotcpserver.h
├── qasiotcpsocket.h
└── tcpabstractsocket.h
├── src
├── include_asio
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── asio.hpp
│ └── asio
│ │ ├── async_result.hpp
│ │ ├── basic_datagram_socket.hpp
│ │ ├── basic_deadline_timer.hpp
│ │ ├── basic_io_object.hpp
│ │ ├── basic_raw_socket.hpp
│ │ ├── basic_seq_packet_socket.hpp
│ │ ├── basic_serial_port.hpp
│ │ ├── basic_signal_set.hpp
│ │ ├── basic_socket.hpp
│ │ ├── basic_socket_acceptor.hpp
│ │ ├── basic_socket_iostream.hpp
│ │ ├── basic_socket_streambuf.hpp
│ │ ├── basic_stream_socket.hpp
│ │ ├── basic_streambuf.hpp
│ │ ├── basic_streambuf_fwd.hpp
│ │ ├── basic_waitable_timer.hpp
│ │ ├── buffer.hpp
│ │ ├── buffered_read_stream.hpp
│ │ ├── buffered_read_stream_fwd.hpp
│ │ ├── buffered_stream.hpp
│ │ ├── buffered_stream_fwd.hpp
│ │ ├── buffered_write_stream.hpp
│ │ ├── buffered_write_stream_fwd.hpp
│ │ ├── buffers_iterator.hpp
│ │ ├── completion_condition.hpp
│ │ ├── connect.hpp
│ │ ├── coroutine.hpp
│ │ ├── datagram_socket_service.hpp
│ │ ├── deadline_timer.hpp
│ │ ├── deadline_timer_service.hpp
│ │ ├── detail
│ │ ├── addressof.hpp
│ │ ├── array.hpp
│ │ ├── array_fwd.hpp
│ │ ├── assert.hpp
│ │ ├── atomic_count.hpp
│ │ ├── base_from_completion_cond.hpp
│ │ ├── bind_handler.hpp
│ │ ├── buffer_resize_guard.hpp
│ │ ├── buffer_sequence_adapter.hpp
│ │ ├── buffered_stream_storage.hpp
│ │ ├── call_stack.hpp
│ │ ├── chrono_time_traits.hpp
│ │ ├── completion_handler.hpp
│ │ ├── config.hpp
│ │ ├── consuming_buffers.hpp
│ │ ├── cstdint.hpp
│ │ ├── date_time_fwd.hpp
│ │ ├── deadline_timer_service.hpp
│ │ ├── dependent_type.hpp
│ │ ├── descriptor_ops.hpp
│ │ ├── descriptor_read_op.hpp
│ │ ├── descriptor_write_op.hpp
│ │ ├── dev_poll_reactor.hpp
│ │ ├── epoll_reactor.hpp
│ │ ├── event.hpp
│ │ ├── eventfd_select_interrupter.hpp
│ │ ├── fd_set_adapter.hpp
│ │ ├── fenced_block.hpp
│ │ ├── function.hpp
│ │ ├── gcc_arm_fenced_block.hpp
│ │ ├── gcc_hppa_fenced_block.hpp
│ │ ├── gcc_sync_fenced_block.hpp
│ │ ├── gcc_x86_fenced_block.hpp
│ │ ├── handler_alloc_helpers.hpp
│ │ ├── handler_cont_helpers.hpp
│ │ ├── handler_invoke_helpers.hpp
│ │ ├── handler_tracking.hpp
│ │ ├── handler_type_requirements.hpp
│ │ ├── hash_map.hpp
│ │ ├── impl
│ │ │ ├── buffer_sequence_adapter.ipp
│ │ │ ├── descriptor_ops.ipp
│ │ │ ├── dev_poll_reactor.hpp
│ │ │ ├── dev_poll_reactor.ipp
│ │ │ ├── epoll_reactor.hpp
│ │ │ ├── epoll_reactor.ipp
│ │ │ ├── eventfd_select_interrupter.ipp
│ │ │ ├── handler_tracking.ipp
│ │ │ ├── kqueue_reactor.hpp
│ │ │ ├── kqueue_reactor.ipp
│ │ │ ├── pipe_select_interrupter.ipp
│ │ │ ├── posix_event.ipp
│ │ │ ├── posix_mutex.ipp
│ │ │ ├── posix_thread.ipp
│ │ │ ├── posix_tss_ptr.ipp
│ │ │ ├── reactive_descriptor_service.ipp
│ │ │ ├── reactive_serial_port_service.ipp
│ │ │ ├── reactive_socket_service_base.ipp
│ │ │ ├── resolver_service_base.ipp
│ │ │ ├── select_reactor.hpp
│ │ │ ├── select_reactor.ipp
│ │ │ ├── service_registry.hpp
│ │ │ ├── service_registry.ipp
│ │ │ ├── signal_set_service.ipp
│ │ │ ├── socket_ops.ipp
│ │ │ ├── socket_select_interrupter.ipp
│ │ │ ├── strand_service.hpp
│ │ │ ├── strand_service.ipp
│ │ │ ├── task_io_service.hpp
│ │ │ ├── task_io_service.ipp
│ │ │ ├── throw_error.ipp
│ │ │ ├── timer_queue_ptime.ipp
│ │ │ ├── timer_queue_set.ipp
│ │ │ ├── win_event.ipp
│ │ │ ├── win_iocp_handle_service.ipp
│ │ │ ├── win_iocp_io_service.hpp
│ │ │ ├── win_iocp_io_service.ipp
│ │ │ ├── win_iocp_serial_port_service.ipp
│ │ │ ├── win_iocp_socket_service_base.ipp
│ │ │ ├── win_mutex.ipp
│ │ │ ├── win_object_handle_service.ipp
│ │ │ ├── win_static_mutex.ipp
│ │ │ ├── win_thread.ipp
│ │ │ ├── win_tss_ptr.ipp
│ │ │ ├── winrt_ssocket_service_base.ipp
│ │ │ ├── winrt_timer_scheduler.hpp
│ │ │ ├── winrt_timer_scheduler.ipp
│ │ │ └── winsock_init.ipp
│ │ ├── io_control.hpp
│ │ ├── keyword_tss_ptr.hpp
│ │ ├── kqueue_reactor.hpp
│ │ ├── limits.hpp
│ │ ├── local_free_on_block_exit.hpp
│ │ ├── macos_fenced_block.hpp
│ │ ├── mutex.hpp
│ │ ├── noncopyable.hpp
│ │ ├── null_event.hpp
│ │ ├── null_fenced_block.hpp
│ │ ├── null_mutex.hpp
│ │ ├── null_reactor.hpp
│ │ ├── null_signal_blocker.hpp
│ │ ├── null_socket_service.hpp
│ │ ├── null_static_mutex.hpp
│ │ ├── null_thread.hpp
│ │ ├── null_tss_ptr.hpp
│ │ ├── object_pool.hpp
│ │ ├── old_win_sdk_compat.hpp
│ │ ├── op_queue.hpp
│ │ ├── operation.hpp
│ │ ├── pipe_select_interrupter.hpp
│ │ ├── pop_options.hpp
│ │ ├── posix_event.hpp
│ │ ├── posix_fd_set_adapter.hpp
│ │ ├── posix_mutex.hpp
│ │ ├── posix_signal_blocker.hpp
│ │ ├── posix_static_mutex.hpp
│ │ ├── posix_thread.hpp
│ │ ├── posix_tss_ptr.hpp
│ │ ├── push_options.hpp
│ │ ├── reactive_descriptor_service.hpp
│ │ ├── reactive_null_buffers_op.hpp
│ │ ├── reactive_serial_port_service.hpp
│ │ ├── reactive_socket_accept_op.hpp
│ │ ├── reactive_socket_connect_op.hpp
│ │ ├── reactive_socket_recv_op.hpp
│ │ ├── reactive_socket_recvfrom_op.hpp
│ │ ├── reactive_socket_recvmsg_op.hpp
│ │ ├── reactive_socket_send_op.hpp
│ │ ├── reactive_socket_sendto_op.hpp
│ │ ├── reactive_socket_service.hpp
│ │ ├── reactive_socket_service_base.hpp
│ │ ├── reactor.hpp
│ │ ├── reactor_fwd.hpp
│ │ ├── reactor_op.hpp
│ │ ├── reactor_op_queue.hpp
│ │ ├── regex_fwd.hpp
│ │ ├── resolve_endpoint_op.hpp
│ │ ├── resolve_op.hpp
│ │ ├── resolver_service.hpp
│ │ ├── resolver_service_base.hpp
│ │ ├── scoped_lock.hpp
│ │ ├── scoped_ptr.hpp
│ │ ├── select_interrupter.hpp
│ │ ├── select_reactor.hpp
│ │ ├── service_registry.hpp
│ │ ├── shared_ptr.hpp
│ │ ├── signal_blocker.hpp
│ │ ├── signal_handler.hpp
│ │ ├── signal_init.hpp
│ │ ├── signal_op.hpp
│ │ ├── signal_set_service.hpp
│ │ ├── socket_holder.hpp
│ │ ├── socket_ops.hpp
│ │ ├── socket_option.hpp
│ │ ├── socket_select_interrupter.hpp
│ │ ├── socket_types.hpp
│ │ ├── solaris_fenced_block.hpp
│ │ ├── static_mutex.hpp
│ │ ├── std_event.hpp
│ │ ├── std_mutex.hpp
│ │ ├── std_static_mutex.hpp
│ │ ├── std_thread.hpp
│ │ ├── strand_service.hpp
│ │ ├── task_io_service.hpp
│ │ ├── task_io_service_operation.hpp
│ │ ├── task_io_service_thread_info.hpp
│ │ ├── thread.hpp
│ │ ├── thread_info_base.hpp
│ │ ├── throw_error.hpp
│ │ ├── throw_exception.hpp
│ │ ├── timer_queue.hpp
│ │ ├── timer_queue_base.hpp
│ │ ├── timer_queue_ptime.hpp
│ │ ├── timer_queue_set.hpp
│ │ ├── timer_scheduler.hpp
│ │ ├── timer_scheduler_fwd.hpp
│ │ ├── tss_ptr.hpp
│ │ ├── type_traits.hpp
│ │ ├── variadic_templates.hpp
│ │ ├── wait_handler.hpp
│ │ ├── wait_op.hpp
│ │ ├── weak_ptr.hpp
│ │ ├── win_event.hpp
│ │ ├── win_fd_set_adapter.hpp
│ │ ├── win_fenced_block.hpp
│ │ ├── win_iocp_handle_read_op.hpp
│ │ ├── win_iocp_handle_service.hpp
│ │ ├── win_iocp_handle_write_op.hpp
│ │ ├── win_iocp_io_service.hpp
│ │ ├── win_iocp_null_buffers_op.hpp
│ │ ├── win_iocp_operation.hpp
│ │ ├── win_iocp_overlapped_op.hpp
│ │ ├── win_iocp_overlapped_ptr.hpp
│ │ ├── win_iocp_serial_port_service.hpp
│ │ ├── win_iocp_socket_accept_op.hpp
│ │ ├── win_iocp_socket_connect_op.hpp
│ │ ├── win_iocp_socket_recv_op.hpp
│ │ ├── win_iocp_socket_recvfrom_op.hpp
│ │ ├── win_iocp_socket_recvmsg_op.hpp
│ │ ├── win_iocp_socket_send_op.hpp
│ │ ├── win_iocp_socket_service.hpp
│ │ ├── win_iocp_socket_service_base.hpp
│ │ ├── win_iocp_thread_info.hpp
│ │ ├── win_mutex.hpp
│ │ ├── win_object_handle_service.hpp
│ │ ├── win_static_mutex.hpp
│ │ ├── win_thread.hpp
│ │ ├── win_tss_ptr.hpp
│ │ ├── wince_thread.hpp
│ │ ├── winrt_async_manager.hpp
│ │ ├── winrt_async_op.hpp
│ │ ├── winrt_resolve_op.hpp
│ │ ├── winrt_resolver_service.hpp
│ │ ├── winrt_socket_connect_op.hpp
│ │ ├── winrt_socket_recv_op.hpp
│ │ ├── winrt_socket_send_op.hpp
│ │ ├── winrt_ssocket_service.hpp
│ │ ├── winrt_ssocket_service_base.hpp
│ │ ├── winrt_timer_scheduler.hpp
│ │ ├── winrt_utils.hpp
│ │ ├── winsock_init.hpp
│ │ └── wrapped_handler.hpp
│ │ ├── error.hpp
│ │ ├── error_code.hpp
│ │ ├── generic
│ │ ├── basic_endpoint.hpp
│ │ ├── datagram_protocol.hpp
│ │ ├── detail
│ │ │ ├── endpoint.hpp
│ │ │ └── impl
│ │ │ │ └── endpoint.ipp
│ │ ├── raw_protocol.hpp
│ │ ├── seq_packet_protocol.hpp
│ │ └── stream_protocol.hpp
│ │ ├── handler_alloc_hook.hpp
│ │ ├── handler_continuation_hook.hpp
│ │ ├── handler_invoke_hook.hpp
│ │ ├── handler_type.hpp
│ │ ├── high_resolution_timer.hpp
│ │ ├── impl
│ │ ├── buffered_read_stream.hpp
│ │ ├── buffered_write_stream.hpp
│ │ ├── connect.hpp
│ │ ├── error.ipp
│ │ ├── error_code.ipp
│ │ ├── handler_alloc_hook.ipp
│ │ ├── io_service.hpp
│ │ ├── io_service.ipp
│ │ ├── read.hpp
│ │ ├── read_at.hpp
│ │ ├── read_until.hpp
│ │ ├── serial_port_base.hpp
│ │ ├── serial_port_base.ipp
│ │ ├── spawn.hpp
│ │ ├── src.cpp
│ │ ├── src.hpp
│ │ ├── use_future.hpp
│ │ ├── write.hpp
│ │ └── write_at.hpp
│ │ ├── io_service.hpp
│ │ ├── ip
│ │ ├── address.hpp
│ │ ├── address_v4.hpp
│ │ ├── address_v6.hpp
│ │ ├── basic_endpoint.hpp
│ │ ├── basic_resolver.hpp
│ │ ├── basic_resolver_entry.hpp
│ │ ├── basic_resolver_iterator.hpp
│ │ ├── basic_resolver_query.hpp
│ │ ├── detail
│ │ │ ├── endpoint.hpp
│ │ │ ├── impl
│ │ │ │ └── endpoint.ipp
│ │ │ └── socket_option.hpp
│ │ ├── host_name.hpp
│ │ ├── icmp.hpp
│ │ ├── impl
│ │ │ ├── address.hpp
│ │ │ ├── address.ipp
│ │ │ ├── address_v4.hpp
│ │ │ ├── address_v4.ipp
│ │ │ ├── address_v6.hpp
│ │ │ ├── address_v6.ipp
│ │ │ ├── basic_endpoint.hpp
│ │ │ └── host_name.ipp
│ │ ├── multicast.hpp
│ │ ├── resolver_query_base.hpp
│ │ ├── resolver_service.hpp
│ │ ├── tcp.hpp
│ │ ├── udp.hpp
│ │ ├── unicast.hpp
│ │ └── v6_only.hpp
│ │ ├── is_read_buffered.hpp
│ │ ├── is_write_buffered.hpp
│ │ ├── local
│ │ ├── basic_endpoint.hpp
│ │ ├── connect_pair.hpp
│ │ ├── datagram_protocol.hpp
│ │ ├── detail
│ │ │ ├── endpoint.hpp
│ │ │ └── impl
│ │ │ │ └── endpoint.ipp
│ │ └── stream_protocol.hpp
│ │ ├── placeholders.hpp
│ │ ├── posix
│ │ ├── basic_descriptor.hpp
│ │ ├── basic_stream_descriptor.hpp
│ │ ├── descriptor_base.hpp
│ │ ├── stream_descriptor.hpp
│ │ └── stream_descriptor_service.hpp
│ │ ├── raw_socket_service.hpp
│ │ ├── read.hpp
│ │ ├── read_at.hpp
│ │ ├── read_until.hpp
│ │ ├── seq_packet_socket_service.hpp
│ │ ├── serial_port.hpp
│ │ ├── serial_port_base.hpp
│ │ ├── serial_port_service.hpp
│ │ ├── signal_set.hpp
│ │ ├── signal_set_service.hpp
│ │ ├── socket_acceptor_service.hpp
│ │ ├── socket_base.hpp
│ │ ├── spawn.hpp
│ │ ├── ssl.hpp
│ │ ├── ssl
│ │ ├── basic_context.hpp
│ │ ├── context.hpp
│ │ ├── context_base.hpp
│ │ ├── context_service.hpp
│ │ ├── detail
│ │ │ ├── buffered_handshake_op.hpp
│ │ │ ├── engine.hpp
│ │ │ ├── handshake_op.hpp
│ │ │ ├── impl
│ │ │ │ ├── engine.ipp
│ │ │ │ └── openssl_init.ipp
│ │ │ ├── io.hpp
│ │ │ ├── openssl_init.hpp
│ │ │ ├── openssl_types.hpp
│ │ │ ├── password_callback.hpp
│ │ │ ├── read_op.hpp
│ │ │ ├── shutdown_op.hpp
│ │ │ ├── stream_core.hpp
│ │ │ ├── verify_callback.hpp
│ │ │ └── write_op.hpp
│ │ ├── error.hpp
│ │ ├── impl
│ │ │ ├── context.hpp
│ │ │ ├── context.ipp
│ │ │ ├── error.ipp
│ │ │ ├── rfc2818_verification.ipp
│ │ │ └── src.hpp
│ │ ├── old
│ │ │ ├── basic_context.hpp
│ │ │ ├── context_service.hpp
│ │ │ ├── detail
│ │ │ │ ├── openssl_context_service.hpp
│ │ │ │ ├── openssl_operation.hpp
│ │ │ │ └── openssl_stream_service.hpp
│ │ │ ├── stream.hpp
│ │ │ └── stream_service.hpp
│ │ ├── rfc2818_verification.hpp
│ │ ├── stream.hpp
│ │ ├── stream_base.hpp
│ │ ├── stream_service.hpp
│ │ ├── verify_context.hpp
│ │ └── verify_mode.hpp
│ │ ├── steady_timer.hpp
│ │ ├── strand.hpp
│ │ ├── stream_socket_service.hpp
│ │ ├── streambuf.hpp
│ │ ├── system_error.hpp
│ │ ├── system_timer.hpp
│ │ ├── thread.hpp
│ │ ├── time_traits.hpp
│ │ ├── unyield.hpp
│ │ ├── use_future.hpp
│ │ ├── version.hpp
│ │ ├── wait_traits.hpp
│ │ ├── waitable_timer_service.hpp
│ │ ├── windows
│ │ ├── basic_handle.hpp
│ │ ├── basic_object_handle.hpp
│ │ ├── basic_random_access_handle.hpp
│ │ ├── basic_stream_handle.hpp
│ │ ├── object_handle.hpp
│ │ ├── object_handle_service.hpp
│ │ ├── overlapped_ptr.hpp
│ │ ├── random_access_handle.hpp
│ │ ├── random_access_handle_service.hpp
│ │ ├── stream_handle.hpp
│ │ └── stream_handle_service.hpp
│ │ ├── write.hpp
│ │ ├── write_at.hpp
│ │ └── yield.hpp
├── ioserviceclass.h
├── linstenclass.hpp
├── qasiosocket.h
├── qasiosslserver.cpp
├── qasiosslserver.h
├── qasiosslsocket.cpp
├── qasiosslsocket.h
├── qasiotcpserver.cpp
├── qasiotcpserver.h
├── qasiotcpsocket.cpp
├── qasiotcpsocket.h
├── qsocketconnection.cpp
├── qsocketconnection.h
├── src.pro
└── tcpabstractsocket.h
└── test
├── client
├── client.pro
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
└── mainwindow.ui
├── msslserver
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── msslserver.pro
├── testserver.cpp
└── testserver.h
├── myserver
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── myserver.pro
├── testserver.cpp
└── testserver.h
├── server
├── main.cpp
├── server.pro
├── testserver.cpp
└── testserver.h
├── sslserver
├── Jamfile
├── Jamfile.v2
├── ca.pem
├── dh512.pem
├── main.cpp
├── server.pem
├── sslserver.pro
├── testserver.cpp
└── testserver.h
└── test.pro
/.gitignore:
--------------------------------------------------------------------------------
1 | *.user
2 | *.user.*
3 | lib
--------------------------------------------------------------------------------
/QAsioSocket.pri:
--------------------------------------------------------------------------------
1 | INCLUDEPATH += $$PWD/src/include_asio/
2 | INCLUDEPATH += $$PWD/src/
3 |
4 | win32:win32-g++:LIBS += -lMswsock
5 | win32:LIBS += -lws2_32
6 |
7 | DEFINES += ASIO_STANDALONE
8 |
9 | CONFIG += c++11
10 |
11 | HEADERS += \
12 | $$PWD/src/ioserviceclass.h \
13 | $$PWD/include/tcpabstractsocket.h \
14 | $$PWD/include/qasiotcpsocket.h \
15 | $$PWD/include/qasiotcpserver.h \
16 | $$PWD/src/linstenclass.hpp \
17 | $$PWD/src/qsocketconnection.h \
18 | $$PWD/include/qasiosslsocket.h \
19 | $$PWD/include/qasiosslserver.h \
20 | $$PWD/include/qasiosocket.h
21 |
22 | SOURCES += \
23 | $$PWD/src/qasiotcpsocket.cpp \
24 | $$PWD/src/qasiotcpserver.cpp \
25 | $$PWD/src/qsocketconnection.cpp \
26 | $$PWD/src/qasiosslsocket.cpp \
27 | $$PWD/src/qasiosslserver.cpp
28 |
--------------------------------------------------------------------------------
/QAsioSocket.pro:
--------------------------------------------------------------------------------
1 | TEMPLATE = subdirs
2 | CONFIG += ordered
3 |
4 | SUBDIRS = src test
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QAsioTcpSocket
2 | 把asio的socket操作封装成类似Qt Network类似的简单的api。
3 |
4 | ****************************************
5 | ###优点,目的:
6 | API 使用简单优雅。封装完全隐藏asio实现的细节。
7 | 不依赖Boost。可以直接包含代码使用,也可以编译成动态库。
8 |
9 | ###比较Qt的socket :
10 | 效率高:充分利用平台特性,win(iocp),linux(epoll)。而Qt的socekt都是select。
11 | 并发高:个人不准确测试,当QTcpServer接受900+连接后就不能在接受新的连接了。而QAsioTcpServer几千个很轻松。
12 |
13 | **************************
14 | ###使用方法:
15 | 1.Build:
16 | 直接用Qt-Creator 打开项目(QAsioSocket.pro),然后打开src.pro文件.
17 | 然后编译,生成的动态库在lib文件夹下,头文件就是include文件夹下的。
18 | 2.直接使用源码:
19 | 把代码复制到您的项目目录下去。
20 | 在pro文件中包含include(QAsioSocket/QAsioSocket.pri),
21 | 添加宏定义 DEFINES += QASIOSOCKET_NOLIB 到您的pro文件。
22 |
23 | **************************************
24 | ###环境依赖
25 | 依赖库:Qt 5.x(Just Use Core Module), asio(Non Boost.已经在源码里包含了)
26 | windows: vs2013 + , mingw 4.9 +
27 | linux : gcc 4.8 +
28 |
29 | ***************************************
30 | ###启用SSL:
31 | SSL连接只实现了服务端,可以做ssl socket的服务器,但是没有客户端接口去连接远程SSL 服务器。
32 | 启用SSL 的库编译:
33 | 在src.pro工程文件里添加:DEFINES += QASIO_SSL (取消哪行注视也行)
34 | 添加openssl的库引用。
35 | 直接使用源码的话,请在您的工程文件(pro)文件里加上宏QASIO_SSL。并添加openssl的库引用。
36 |
37 |
--------------------------------------------------------------------------------
/include/qasiosocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOSOCKET_H
2 | #define QASIOSOCKET_H
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #if defined(QASIOSOCKET_NOLIB)
10 |
11 | #define QASIOSOCKET_EXPORT
12 |
13 | #elif defined(QASIOSOCKET_LIBRARY)
14 |
15 | #define QASIOSOCKET_EXPORT Q_DECL_EXPORT
16 |
17 | #else
18 |
19 | #define QASIOSOCKET_EXPORT Q_DECL_IMPORT
20 |
21 | #endif
22 |
23 |
24 | //#define QASIOSOCKET_EXPORT Q_CORE_EXPORT
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/include/qasiosslsocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOSSLSOCKET_H
2 | #define QASIOSSLSOCKET_H
3 |
4 | #include "tcpabstractsocket.h"
5 | #ifdef QASIO_SSL
6 |
7 | class SSLSession;
8 |
9 | class QASIOSOCKET_EXPORT QAsioSslSocket : public TcpAbstractSocket
10 | {
11 | Q_OBJECT
12 | public:
13 | QAsioSslSocket(SSLSession * session);
14 | virtual ~QAsioSslSocket();
15 | public slots:
16 | void disconnectFromHost();
17 |
18 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
19 |
20 | std::pair getSocketOption(TcpAbstractSocket::SocketOption);
21 |
22 | void do_start();
23 | protected slots:
24 | void sendData(const char * data, int size);
25 | void connectToHost(const QString &/*hostName*/, quint16 /*port*/)
26 | {}
27 | private:
28 | SSLSession * con_;
29 | Q_DISABLE_COPY(QAsioSslSocket)
30 | };
31 |
32 | #endif //asio_ssl
33 |
34 | #endif // QASIOSSLSOCKET_H
35 |
--------------------------------------------------------------------------------
/include/qasiotcpserver.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOTCPSERVER_H
2 | #define QASIOTCPSERVER_H
3 |
4 | #include "qasiotcpsocket.h"
5 |
6 | struct SocketSession;
7 | struct Session;
8 |
9 | class QASIOSOCKET_EXPORT QAsioTcpServer : public QObject
10 | {
11 | Q_OBJECT
12 | public:
13 | explicit QAsioTcpServer(size_t socket_buffer = 4096,QObject *parent = 0);
14 | ~QAsioTcpServer();
15 |
16 | signals:
17 | void newConnection(QAsioTcpsocket * socket);
18 |
19 | void deleteAllLink();
20 | public :
21 | bool listen(const QString & ip,qint16 port);
22 | bool listen(qint16 port,bool isV6 = false);
23 |
24 | void close();
25 |
26 | void setSocketOption(TcpAbstractSocket::SocketOption option, uint value) {
27 | setSocketOption(option,false,value);
28 | }
29 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble) {
30 | setSocketOption(option,isEnble,0);
31 | }
32 |
33 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
34 |
35 | int setThreadSize(int size);
36 | protected:
37 | virtual void incomingConnection(Session * session);
38 | private:
39 | SocketSession * listen_session;
40 | friend struct SocketSession;
41 | };
42 |
43 | #endif // QASIOTCPSERVER_H
44 |
--------------------------------------------------------------------------------
/include/qasiotcpsocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOTCPSOCKET_H
2 | #define QASIOTCPSOCKET_H
3 | #include "tcpabstractsocket.h"
4 |
5 | struct Session;
6 | class IOServiceClass;
7 |
8 | class QASIOSOCKET_EXPORT QAsioTcpsocket : public TcpAbstractSocket
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit QAsioTcpsocket(size_t size = 4096,QObject *parent = 0);
13 | QAsioTcpsocket(Session *ses);
14 | ~QAsioTcpsocket();
15 |
16 | signals:
17 |
18 | public slots:
19 | void connectToHost(const QString &hostName, quint16 port);
20 |
21 | void disconnectFromHost();
22 |
23 | virtual void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
24 |
25 | virtual std::pair getSocketOption(TcpAbstractSocket::SocketOption opention);
26 |
27 | void do_start();
28 |
29 | int resizeClientBackThreadSize(int size);
30 | protected:
31 | virtual void hostConnected();
32 | void sendData(const char * data, int size);
33 | private:
34 | bool serverBuild;
35 | Session * con_;
36 | static IOServiceClass * ioserver;
37 | static volatile ulong linkCout;
38 | Q_DISABLE_COPY(QAsioTcpsocket)
39 | };
40 |
41 | #endif // QASIOTCPSOCKET_H
42 |
--------------------------------------------------------------------------------
/src/include_asio/asio/basic_streambuf_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // basic_streambuf_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_BASIC_STREAMBUF_FWD_HPP
12 | #define ASIO_BASIC_STREAMBUF_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_NO_IOSTREAM)
21 |
22 | #include
23 |
24 | namespace asio {
25 |
26 | template >
27 | class basic_streambuf;
28 |
29 | } // namespace asio
30 |
31 | #endif // !defined(ASIO_NO_IOSTREAM)
32 |
33 | #endif // ASIO_BASIC_STREAMBUF_FWD_HPP
34 |
--------------------------------------------------------------------------------
/src/include_asio/asio/buffered_read_stream_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // buffered_read_stream_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_BUFFERED_READ_STREAM_FWD_HPP
12 | #define ASIO_BUFFERED_READ_STREAM_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | namespace asio {
19 |
20 | template
21 | class buffered_read_stream;
22 |
23 | } // namespace asio
24 |
25 | #endif // ASIO_BUFFERED_READ_STREAM_FWD_HPP
26 |
--------------------------------------------------------------------------------
/src/include_asio/asio/buffered_stream_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // buffered_stream_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_BUFFERED_STREAM_FWD_HPP
12 | #define ASIO_BUFFERED_STREAM_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | namespace asio {
19 |
20 | template
21 | class buffered_stream;
22 |
23 | } // namespace asio
24 |
25 | #endif // ASIO_BUFFERED_STREAM_FWD_HPP
26 |
--------------------------------------------------------------------------------
/src/include_asio/asio/buffered_write_stream_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // buffered_write_stream_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_BUFFERED_WRITE_STREAM_FWD_HPP
12 | #define ASIO_BUFFERED_WRITE_STREAM_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | namespace asio {
19 |
20 | template
21 | class buffered_write_stream;
22 |
23 | } // namespace asio
24 |
25 | #endif // ASIO_BUFFERED_WRITE_STREAM_FWD_HPP
26 |
--------------------------------------------------------------------------------
/src/include_asio/asio/deadline_timer.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // deadline_timer.hpp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DEADLINE_TIMER_HPP
12 | #define ASIO_DEADLINE_TIMER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_BOOST_DATE_TIME) \
21 | || defined(GENERATING_DOCUMENTATION)
22 |
23 | #include "asio/detail/socket_types.hpp" // Must come before posix_time.
24 | #include "asio/basic_deadline_timer.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 | #include
28 | #include "asio/detail/pop_options.hpp"
29 |
30 | namespace asio {
31 |
32 | /// Typedef for the typical usage of timer. Uses a UTC clock.
33 | typedef basic_deadline_timer deadline_timer;
34 |
35 | } // namespace asio
36 |
37 | #endif // defined(ASIO_HAS_BOOST_DATE_TIME)
38 | // || defined(GENERATING_DOCUMENTATION)
39 |
40 | #endif // ASIO_DEADLINE_TIMER_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/addressof.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/addressof.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_ADDRESSOF_HPP
12 | #define ASIO_DETAIL_ADDRESSOF_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_ADDRESSOF)
21 | # include
22 | #else // defined(ASIO_HAS_STD_ADDRESSOF)
23 | # include
24 | #endif // defined(ASIO_HAS_STD_ADDRESSOF)
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_STD_ADDRESSOF)
30 | using std::addressof;
31 | #else // defined(ASIO_HAS_STD_ADDRESSOF)
32 | using boost::addressof;
33 | #endif // defined(ASIO_HAS_STD_ADDRESSOF)
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_ADDRESSOF_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/array.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/array.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_ARRAY_HPP
12 | #define ASIO_DETAIL_ARRAY_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_ARRAY)
21 | # include
22 | #else // defined(ASIO_HAS_STD_ARRAY)
23 | # include
24 | #endif // defined(ASIO_HAS_STD_ARRAY)
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_STD_ARRAY)
30 | using std::array;
31 | #else // defined(ASIO_HAS_STD_ARRAY)
32 | using boost::array;
33 | #endif // defined(ASIO_HAS_STD_ARRAY)
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_ARRAY_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/array_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/array_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_ARRAY_FWD_HPP
12 | #define ASIO_DETAIL_ARRAY_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | namespace boost {
21 |
22 | template
23 | class array;
24 |
25 | } // namespace boost
26 |
27 | // Standard library components can't be forward declared, so we'll have to
28 | // include the array header. Fortunately, it's fairly lightweight and doesn't
29 | // add significantly to the compile time.
30 | #if defined(ASIO_HAS_STD_ARRAY)
31 | # include
32 | #endif // defined(ASIO_HAS_STD_ARRAY)
33 |
34 | #endif // ASIO_DETAIL_ARRAY_FWD_HPP
35 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/assert.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/assert.hpp
3 | // ~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_ASSERT_HPP
12 | #define ASIO_DETAIL_ASSERT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_BOOST_ASSERT)
21 | # include
22 | #else // defined(ASIO_HAS_BOOST_ASSERT)
23 | # include
24 | #endif // defined(ASIO_HAS_BOOST_ASSERT)
25 |
26 | #if defined(ASIO_HAS_BOOST_ASSERT)
27 | # define ASIO_ASSERT(expr) BOOST_ASSERT(expr)
28 | #else // defined(ASIO_HAS_BOOST_ASSERT)
29 | # define ASIO_ASSERT(expr) assert(expr)
30 | #endif // defined(ASIO_HAS_BOOST_ASSERT)
31 |
32 | #endif // ASIO_DETAIL_ASSERT_HPP
33 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/atomic_count.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/atomic_count.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_ATOMIC_COUNT_HPP
12 | #define ASIO_DETAIL_ATOMIC_COUNT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | // Nothing to include.
22 | #elif defined(ASIO_HAS_STD_ATOMIC)
23 | # include
24 | #else // defined(ASIO_HAS_STD_ATOMIC)
25 | # include
26 | #endif // defined(ASIO_HAS_STD_ATOMIC)
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | #if !defined(ASIO_HAS_THREADS)
32 | typedef long atomic_count;
33 | inline void increment(atomic_count& a, long b) { a += b; }
34 | #elif defined(ASIO_HAS_STD_ATOMIC)
35 | typedef std::atomic atomic_count;
36 | inline void increment(atomic_count& a, long b) { a += b; }
37 | #else // defined(ASIO_HAS_STD_ATOMIC)
38 | typedef boost::detail::atomic_count atomic_count;
39 | inline void increment(atomic_count& a, long b) { while (b > 0) ++a, --b; }
40 | #endif // defined(ASIO_HAS_STD_ATOMIC)
41 |
42 | } // namespace detail
43 | } // namespace asio
44 |
45 | #endif // ASIO_DETAIL_ATOMIC_COUNT_HPP
46 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/base_from_completion_cond.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/base_from_completion_cond.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
12 | #define ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/completion_condition.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | template
27 | class base_from_completion_cond
28 | {
29 | protected:
30 | explicit base_from_completion_cond(CompletionCondition completion_condition)
31 | : completion_condition_(completion_condition)
32 | {
33 | }
34 |
35 | std::size_t check_for_completion(
36 | const asio::error_code& ec,
37 | std::size_t total_transferred)
38 | {
39 | return detail::adapt_completion_condition_result(
40 | completion_condition_(ec, total_transferred));
41 | }
42 |
43 | private:
44 | CompletionCondition completion_condition_;
45 | };
46 |
47 | template <>
48 | class base_from_completion_cond
49 | {
50 | protected:
51 | explicit base_from_completion_cond(transfer_all_t)
52 | {
53 | }
54 |
55 | static std::size_t check_for_completion(
56 | const asio::error_code& ec,
57 | std::size_t total_transferred)
58 | {
59 | return transfer_all_t()(ec, total_transferred);
60 | }
61 | };
62 |
63 | } // namespace detail
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #endif // ASIO_DETAIL_BASE_FROM_COMPLETION_COND_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/buffer_resize_guard.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/buffer_resize_guard.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
12 | #define ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/limits.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | // Helper class to manage buffer resizing in an exception safe way.
27 | template
28 | class buffer_resize_guard
29 | {
30 | public:
31 | // Constructor.
32 | buffer_resize_guard(Buffer& buffer)
33 | : buffer_(buffer),
34 | old_size_(buffer.size())
35 | {
36 | }
37 |
38 | // Destructor rolls back the buffer resize unless commit was called.
39 | ~buffer_resize_guard()
40 | {
41 | if (old_size_ != (std::numeric_limits::max)())
42 | {
43 | buffer_.resize(old_size_);
44 | }
45 | }
46 |
47 | // Commit the resize transaction.
48 | void commit()
49 | {
50 | old_size_ = (std::numeric_limits::max)();
51 | }
52 |
53 | private:
54 | // The buffer being managed.
55 | Buffer& buffer_;
56 |
57 | // The size of the buffer at the time the guard was constructed.
58 | size_t old_size_;
59 | };
60 |
61 | } // namespace detail
62 | } // namespace asio
63 |
64 | #include "asio/detail/pop_options.hpp"
65 |
66 | #endif // ASIO_DETAIL_BUFFER_RESIZE_GUARD_HPP
67 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/cstdint.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/cstdint.hpp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_CSTDINT_HPP
12 | #define ASIO_DETAIL_CSTDINT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_CSTDINT)
21 | # include
22 | #else // defined(ASIO_HAS_CSTDINT)
23 | # include
24 | #endif // defined(ASIO_HAS_CSTDINT)
25 |
26 | namespace asio {
27 |
28 | #if defined(ASIO_HAS_CSTDINT)
29 | using std::int16_t;
30 | using std::uint16_t;
31 | using std::int32_t;
32 | using std::uint32_t;
33 | using std::int64_t;
34 | using std::uint64_t;
35 | #else // defined(ASIO_HAS_CSTDINT)
36 | using boost::int16_t;
37 | using boost::uint16_t;
38 | using boost::int32_t;
39 | using boost::uint32_t;
40 | using boost::int64_t;
41 | using boost::uint64_t;
42 | #endif // defined(ASIO_HAS_CSTDINT)
43 |
44 | } // namespace asio
45 |
46 | #endif // ASIO_DETAIL_CSTDINT_HPP
47 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/date_time_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/date_time_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_DATE_TIME_FWD_HPP
12 | #define ASIO_DETAIL_DATE_TIME_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | namespace boost {
21 | namespace date_time {
22 |
23 | template
24 | class base_time;
25 |
26 | } // namespace date_time
27 | namespace posix_time {
28 |
29 | class ptime;
30 |
31 | } // namespace posix_time
32 | } // namespace boost
33 |
34 | #endif // ASIO_DETAIL_DATE_TIME_FWD_HPP
35 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/dependent_type.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/dependent_type.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_DEPENDENT_TYPE_HPP
12 | #define ASIO_DETAIL_DEPENDENT_TYPE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 | namespace detail {
24 |
25 | template
26 | struct dependent_type
27 | {
28 | typedef T type;
29 | };
30 |
31 | } // namespace detail
32 | } // namespace asio
33 |
34 | #include "asio/detail/pop_options.hpp"
35 |
36 | #endif // ASIO_DETAIL_DEPENDENT_TYPE_HPP
37 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/event.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/event.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_EVENT_HPP
12 | #define ASIO_DETAIL_EVENT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | # include "asio/detail/null_event.hpp"
22 | #elif defined(ASIO_WINDOWS)
23 | # include "asio/detail/win_event.hpp"
24 | #elif defined(ASIO_HAS_PTHREADS)
25 | # include "asio/detail/posix_event.hpp"
26 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
27 | # include "asio/detail/std_event.hpp"
28 | #else
29 | # error Only Windows, POSIX and std::condition_variable are supported!
30 | #endif
31 |
32 | namespace asio {
33 | namespace detail {
34 |
35 | #if !defined(ASIO_HAS_THREADS)
36 | typedef null_event event;
37 | #elif defined(ASIO_WINDOWS)
38 | typedef win_event event;
39 | #elif defined(ASIO_HAS_PTHREADS)
40 | typedef posix_event event;
41 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
42 | typedef std_event event;
43 | #endif
44 |
45 | } // namespace detail
46 | } // namespace asio
47 |
48 | #endif // ASIO_DETAIL_EVENT_HPP
49 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/fd_set_adapter.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/fd_set_adapter.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_FD_SET_ADAPTER_HPP
12 | #define ASIO_DETAIL_FD_SET_ADAPTER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_WINDOWS_RUNTIME)
21 |
22 | #include "asio/detail/posix_fd_set_adapter.hpp"
23 | #include "asio/detail/win_fd_set_adapter.hpp"
24 |
25 | namespace asio {
26 | namespace detail {
27 |
28 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
29 | typedef win_fd_set_adapter fd_set_adapter;
30 | #else
31 | typedef posix_fd_set_adapter fd_set_adapter;
32 | #endif
33 |
34 | } // namespace detail
35 | } // namespace asio
36 |
37 | #endif // !defined(ASIO_WINDOWS_RUNTIME)
38 |
39 | #endif // ASIO_DETAIL_FD_SET_ADAPTER_HPP
40 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/function.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/function.hpp
3 | // ~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_FUNCTION_HPP
12 | #define ASIO_DETAIL_FUNCTION_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_FUNCTION)
21 | # include
22 | #else // defined(ASIO_HAS_STD_FUNCTION)
23 | # include
24 | #endif // defined(ASIO_HAS_STD_FUNCTION)
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_STD_FUNCTION)
30 | using std::function;
31 | #else // defined(ASIO_HAS_STD_FUNCTION)
32 | using boost::function;
33 | #endif // defined(ASIO_HAS_STD_FUNCTION)
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_FUNCTION_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/gcc_hppa_fenced_block.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/gcc_hppa_fenced_block.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
12 | #define ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace detail {
26 |
27 | class gcc_hppa_fenced_block
28 | : private noncopyable
29 | {
30 | public:
31 | enum half_t { half };
32 | enum full_t { full };
33 |
34 | // Constructor for a half fenced block.
35 | explicit gcc_hppa_fenced_block(half_t)
36 | {
37 | }
38 |
39 | // Constructor for a full fenced block.
40 | explicit gcc_hppa_fenced_block(full_t)
41 | {
42 | barrier();
43 | }
44 |
45 | // Destructor.
46 | ~gcc_hppa_fenced_block()
47 | {
48 | barrier();
49 | }
50 |
51 | private:
52 | static void barrier()
53 | {
54 | // This is just a placeholder and almost certainly not sufficient.
55 | __asm__ __volatile__ ("" : : : "memory");
56 | }
57 | };
58 |
59 | } // namespace detail
60 | } // namespace asio
61 |
62 | #include "asio/detail/pop_options.hpp"
63 |
64 | #endif // defined(__GNUC__) && (defined(__hppa) || defined(__hppa__))
65 |
66 | #endif // ASIO_DETAIL_GCC_HPPA_FENCED_BLOCK_HPP
67 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/gcc_sync_fenced_block.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/gcc_sync_fenced_block.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
12 | #define ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(__GNUC__) \
21 | && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)) \
22 | && !defined(__INTEL_COMPILER) && !defined(__ICL) \
23 | && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | class gcc_sync_fenced_block
31 | : private noncopyable
32 | {
33 | public:
34 | enum half_or_full_t { half, full };
35 |
36 | // Constructor.
37 | explicit gcc_sync_fenced_block(half_or_full_t)
38 | : value_(0)
39 | {
40 | __sync_lock_test_and_set(&value_, 1);
41 | }
42 |
43 | // Destructor.
44 | ~gcc_sync_fenced_block()
45 | {
46 | __sync_lock_release(&value_);
47 | }
48 |
49 | private:
50 | int value_;
51 | };
52 |
53 | } // namespace detail
54 | } // namespace asio
55 |
56 | #include "asio/detail/pop_options.hpp"
57 |
58 | #endif // defined(__GNUC__)
59 | // && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
60 | // && !defined(__INTEL_COMPILER) && !defined(__ICL)
61 | // && !defined(__ICC) && !defined(__ECC) && !defined(__PATHSCALE__)
62 |
63 | #endif // ASIO_DETAIL_GCC_SYNC_FENCED_BLOCK_HPP
64 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/handler_cont_helpers.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/handler_cont_helpers.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP
12 | #define ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/addressof.hpp"
20 | #include "asio/handler_continuation_hook.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | // Calls to asio_handler_is_continuation must be made from a namespace that
25 | // does not contain overloads of this function. This namespace is defined here
26 | // for that purpose.
27 | namespace asio_handler_cont_helpers {
28 |
29 | template
30 | inline bool is_continuation(Context& context)
31 | {
32 | #if !defined(ASIO_HAS_HANDLER_HOOKS)
33 | return false;
34 | #else
35 | using asio::asio_handler_is_continuation;
36 | return asio_handler_is_continuation(
37 | asio::detail::addressof(context));
38 | #endif
39 | }
40 |
41 | } // namespace asio_handler_cont_helpers
42 |
43 | #include "asio/detail/pop_options.hpp"
44 |
45 | #endif // ASIO_DETAIL_HANDLER_CONT_HELPERS_HPP
46 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/handler_invoke_helpers.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/handler_invoke_helpers.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
12 | #define ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/addressof.hpp"
20 | #include "asio/handler_invoke_hook.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | // Calls to asio_handler_invoke must be made from a namespace that does not
25 | // contain overloads of this function. The asio_handler_invoke_helpers
26 | // namespace is defined here for that purpose.
27 | namespace asio_handler_invoke_helpers {
28 |
29 | template
30 | inline void invoke(Function& function, Context& context)
31 | {
32 | #if !defined(ASIO_HAS_HANDLER_HOOKS)
33 | Function tmp(function);
34 | tmp();
35 | #else
36 | using asio::asio_handler_invoke;
37 | asio_handler_invoke(function, asio::detail::addressof(context));
38 | #endif
39 | }
40 |
41 | template
42 | inline void invoke(const Function& function, Context& context)
43 | {
44 | #if !defined(ASIO_HAS_HANDLER_HOOKS)
45 | Function tmp(function);
46 | tmp();
47 | #else
48 | using asio::asio_handler_invoke;
49 | asio_handler_invoke(function, asio::detail::addressof(context));
50 | #endif
51 | }
52 |
53 | } // namespace asio_handler_invoke_helpers
54 |
55 | #include "asio/detail/pop_options.hpp"
56 |
57 | #endif // ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
58 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/posix_event.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/posix_event.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_POSIX_EVENT_IPP
12 | #define ASIO_DETAIL_IMPL_POSIX_EVENT_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include "asio/detail/posix_event.hpp"
23 | #include "asio/detail/throw_error.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | posix_event::posix_event()
32 | : state_(0)
33 | {
34 | int error = ::pthread_cond_init(&cond_, 0);
35 | asio::error_code ec(error,
36 | asio::error::get_system_category());
37 | asio::detail::throw_error(ec, "event");
38 | }
39 |
40 | } // namespace detail
41 | } // namespace asio
42 |
43 | #include "asio/detail/pop_options.hpp"
44 |
45 | #endif // defined(ASIO_HAS_PTHREADS)
46 |
47 | #endif // ASIO_DETAIL_IMPL_POSIX_EVENT_IPP
48 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/posix_mutex.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/posix_mutex.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP
12 | #define ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include "asio/detail/posix_mutex.hpp"
23 | #include "asio/detail/throw_error.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | posix_mutex::posix_mutex()
32 | {
33 | int error = ::pthread_mutex_init(&mutex_, 0);
34 | asio::error_code ec(error,
35 | asio::error::get_system_category());
36 | asio::detail::throw_error(ec, "mutex");
37 | }
38 |
39 | } // namespace detail
40 | } // namespace asio
41 |
42 | #include "asio/detail/pop_options.hpp"
43 |
44 | #endif // defined(ASIO_HAS_PTHREADS)
45 |
46 | #endif // ASIO_DETAIL_IMPL_POSIX_MUTEX_IPP
47 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/posix_thread.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/posix_thread.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_POSIX_THREAD_IPP
12 | #define ASIO_DETAIL_IMPL_POSIX_THREAD_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include "asio/detail/posix_thread.hpp"
23 | #include "asio/detail/throw_error.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | posix_thread::~posix_thread()
32 | {
33 | if (!joined_)
34 | ::pthread_detach(thread_);
35 | }
36 |
37 | void posix_thread::join()
38 | {
39 | if (!joined_)
40 | {
41 | ::pthread_join(thread_, 0);
42 | joined_ = true;
43 | }
44 | }
45 |
46 | void posix_thread::start_thread(func_base* arg)
47 | {
48 | int error = ::pthread_create(&thread_, 0,
49 | asio_detail_posix_thread_function, arg);
50 | if (error != 0)
51 | {
52 | delete arg;
53 | asio::error_code ec(error,
54 | asio::error::get_system_category());
55 | asio::detail::throw_error(ec, "thread");
56 | }
57 | }
58 |
59 | void* asio_detail_posix_thread_function(void* arg)
60 | {
61 | posix_thread::auto_func_base_ptr func = {
62 | static_cast(arg) };
63 | func.ptr->run();
64 | return 0;
65 | }
66 |
67 | } // namespace detail
68 | } // namespace asio
69 |
70 | #include "asio/detail/pop_options.hpp"
71 |
72 | #endif // defined(ASIO_HAS_PTHREADS)
73 |
74 | #endif // ASIO_DETAIL_IMPL_POSIX_THREAD_IPP
75 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/posix_tss_ptr.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/posix_tss_ptr.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP
12 | #define ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include "asio/detail/posix_tss_ptr.hpp"
23 | #include "asio/detail/throw_error.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | void posix_tss_ptr_create(pthread_key_t& key)
32 | {
33 | int error = ::pthread_key_create(&key, 0);
34 | asio::error_code ec(error,
35 | asio::error::get_system_category());
36 | asio::detail::throw_error(ec, "tss");
37 | }
38 |
39 | } // namespace detail
40 | } // namespace asio
41 |
42 | #include "asio/detail/pop_options.hpp"
43 |
44 | #endif // defined(ASIO_HAS_PTHREADS)
45 |
46 | #endif // ASIO_DETAIL_IMPL_POSIX_TSS_PTR_IPP
47 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/throw_error.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/throw_error.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_THROW_ERROR_IPP
12 | #define ASIO_DETAIL_IMPL_THROW_ERROR_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/throw_error.hpp"
20 | #include "asio/detail/throw_exception.hpp"
21 | #include "asio/system_error.hpp"
22 |
23 | #include "asio/detail/push_options.hpp"
24 |
25 | namespace asio {
26 | namespace detail {
27 |
28 | void do_throw_error(const asio::error_code& err)
29 | {
30 | asio::system_error e(err);
31 | asio::detail::throw_exception(e);
32 | }
33 |
34 | void do_throw_error(const asio::error_code& err, const char* location)
35 | {
36 | // boostify: non-boost code starts here
37 | #if defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
38 | // Microsoft's implementation of std::system_error is non-conformant in that
39 | // it ignores the error code's message when a "what" string is supplied. We'll
40 | // work around this by explicitly formatting the "what" string.
41 | std::string what_msg = location;
42 | what_msg += ": ";
43 | what_msg += err.message();
44 | asio::system_error e(err, what_msg);
45 | asio::detail::throw_exception(e);
46 | #else // defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
47 | // boostify: non-boost code ends here
48 | asio::system_error e(err, location);
49 | asio::detail::throw_exception(e);
50 | // boostify: non-boost code starts here
51 | #endif // defined(ASIO_MSVC) && defined(ASIO_HAS_STD_SYSTEM_ERROR)
52 | // boostify: non-boost code ends here
53 | }
54 |
55 | } // namespace detail
56 | } // namespace asio
57 |
58 | #include "asio/detail/pop_options.hpp"
59 |
60 | #endif // ASIO_DETAIL_IMPL_THROW_ERROR_IPP
61 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/win_event.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/win_event.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_WIN_EVENT_IPP
12 | #define ASIO_DETAIL_IMPL_WIN_EVENT_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS)
21 |
22 | #include "asio/detail/throw_error.hpp"
23 | #include "asio/detail/win_event.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | win_event::win_event()
32 | : state_(0)
33 | {
34 | events_[0] = ::CreateEvent(0, true, false, 0);
35 | if (!events_[0])
36 | {
37 | DWORD last_error = ::GetLastError();
38 | asio::error_code ec(last_error,
39 | asio::error::get_system_category());
40 | asio::detail::throw_error(ec, "event");
41 | }
42 |
43 | events_[1] = ::CreateEvent(0, false, false, 0);
44 | if (!events_[1])
45 | {
46 | DWORD last_error = ::GetLastError();
47 | ::CloseHandle(events_[0]);
48 | asio::error_code ec(last_error,
49 | asio::error::get_system_category());
50 | asio::detail::throw_error(ec, "event");
51 | }
52 | }
53 |
54 | win_event::~win_event()
55 | {
56 | ::CloseHandle(events_[0]);
57 | ::CloseHandle(events_[1]);
58 | }
59 |
60 | } // namespace detail
61 | } // namespace asio
62 |
63 | #include "asio/detail/pop_options.hpp"
64 |
65 | #endif // defined(ASIO_WINDOWS)
66 |
67 | #endif // ASIO_DETAIL_IMPL_WIN_EVENT_IPP
68 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/impl/win_tss_ptr.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/impl/win_tss_ptr.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
12 | #define ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS)
21 |
22 | #include "asio/detail/throw_error.hpp"
23 | #include "asio/detail/win_tss_ptr.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | DWORD win_tss_ptr_create()
32 | {
33 | #if defined(UNDER_CE)
34 | enum { out_of_indexes = 0xFFFFFFFF };
35 | #else
36 | enum { out_of_indexes = TLS_OUT_OF_INDEXES };
37 | #endif
38 |
39 | DWORD tss_key = ::TlsAlloc();
40 | if (tss_key == out_of_indexes)
41 | {
42 | DWORD last_error = ::GetLastError();
43 | asio::error_code ec(last_error,
44 | asio::error::get_system_category());
45 | asio::detail::throw_error(ec, "tss");
46 | }
47 | return tss_key;
48 | }
49 |
50 | } // namespace detail
51 | } // namespace asio
52 |
53 | #include "asio/detail/pop_options.hpp"
54 |
55 | #endif // defined(ASIO_WINDOWS)
56 |
57 | #endif // ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
58 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/keyword_tss_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/keyword_tss_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_KEYWORD_TSS_PTR_HPP
12 | #define ASIO_DETAIL_KEYWORD_TSS_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | template
30 | class keyword_tss_ptr
31 | : private noncopyable
32 | {
33 | public:
34 | // Constructor.
35 | keyword_tss_ptr()
36 | {
37 | }
38 |
39 | // Destructor.
40 | ~keyword_tss_ptr()
41 | {
42 | }
43 |
44 | // Get the value.
45 | operator T*() const
46 | {
47 | return value_;
48 | }
49 |
50 | // Set the value.
51 | void operator=(T* value)
52 | {
53 | value_ = value;
54 | }
55 |
56 | private:
57 | static ASIO_THREAD_KEYWORD T* value_;
58 | };
59 |
60 | template
61 | ASIO_THREAD_KEYWORD T* keyword_tss_ptr::value_;
62 |
63 | } // namespace detail
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #endif // defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
69 |
70 | #endif // ASIO_DETAIL_KEYWORD_TSS_PTR_HPP
71 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/limits.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/limits.hpp
3 | // ~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_LIMITS_HPP
12 | #define ASIO_DETAIL_LIMITS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_BOOST_LIMITS)
21 | # include
22 | #else // defined(ASIO_HAS_BOOST_LIMITS)
23 | # include
24 | #endif // defined(ASIO_HAS_BOOST_LIMITS)
25 |
26 | #endif // ASIO_DETAIL_LIMITS_HPP
27 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/local_free_on_block_exit.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/local_free_on_block_exit.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP
12 | #define ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 | #include "asio/detail/socket_types.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | class local_free_on_block_exit
31 | : private noncopyable
32 | {
33 | public:
34 | // Constructor blocks all signals for the calling thread.
35 | explicit local_free_on_block_exit(void* p)
36 | : p_(p)
37 | {
38 | }
39 |
40 | // Destructor restores the previous signal mask.
41 | ~local_free_on_block_exit()
42 | {
43 | ::LocalFree(p_);
44 | }
45 |
46 | private:
47 | void* p_;
48 | };
49 |
50 | } // namespace detail
51 | } // namespace asio
52 |
53 | #include "asio/detail/pop_options.hpp"
54 |
55 | #endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
56 |
57 | #endif // ASIO_DETAIL_LOCAL_FREE_ON_BLOCK_EXIT_HPP
58 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/macos_fenced_block.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/macos_fenced_block.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP
12 | #define ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(__MACH__) && defined(__APPLE__)
21 |
22 | #include
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | class macos_fenced_block
30 | : private noncopyable
31 | {
32 | public:
33 | enum half_t { half };
34 | enum full_t { full };
35 |
36 | // Constructor for a half fenced block.
37 | explicit macos_fenced_block(half_t)
38 | {
39 | }
40 |
41 | // Constructor for a full fenced block.
42 | explicit macos_fenced_block(full_t)
43 | {
44 | OSMemoryBarrier();
45 | }
46 |
47 | // Destructor.
48 | ~macos_fenced_block()
49 | {
50 | OSMemoryBarrier();
51 | }
52 | };
53 |
54 | } // namespace detail
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // defined(__MACH__) && defined(__APPLE__)
60 |
61 | #endif // ASIO_DETAIL_MACOS_FENCED_BLOCK_HPP
62 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/mutex.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_MUTEX_HPP
12 | #define ASIO_DETAIL_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | # include "asio/detail/null_mutex.hpp"
22 | #elif defined(ASIO_WINDOWS)
23 | # include "asio/detail/win_mutex.hpp"
24 | #elif defined(ASIO_HAS_PTHREADS)
25 | # include "asio/detail/posix_mutex.hpp"
26 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
27 | # include "asio/detail/std_mutex.hpp"
28 | #else
29 | # error Only Windows, POSIX and std::mutex are supported!
30 | #endif
31 |
32 | namespace asio {
33 | namespace detail {
34 |
35 | #if !defined(ASIO_HAS_THREADS)
36 | typedef null_mutex mutex;
37 | #elif defined(ASIO_WINDOWS)
38 | typedef win_mutex mutex;
39 | #elif defined(ASIO_HAS_PTHREADS)
40 | typedef posix_mutex mutex;
41 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
42 | typedef std_mutex mutex;
43 | #endif
44 |
45 | } // namespace detail
46 | } // namespace asio
47 |
48 | #endif // ASIO_DETAIL_MUTEX_HPP
49 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/noncopyable.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/noncopyable.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NONCOPYABLE_HPP
12 | #define ASIO_DETAIL_NONCOPYABLE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 | namespace detail {
24 |
25 | class noncopyable
26 | {
27 | protected:
28 | noncopyable() {}
29 | ~noncopyable() {}
30 | private:
31 | noncopyable(const noncopyable&);
32 | const noncopyable& operator=(const noncopyable&);
33 | };
34 |
35 | } // namespace detail
36 |
37 | using asio::detail::noncopyable;
38 |
39 | } // namespace asio
40 |
41 | #include "asio/detail/pop_options.hpp"
42 |
43 | #endif // ASIO_DETAIL_NONCOPYABLE_HPP
44 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_event.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_event.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_EVENT_HPP
12 | #define ASIO_DETAIL_NULL_EVENT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | class null_event
30 | : private noncopyable
31 | {
32 | public:
33 | // Constructor.
34 | null_event()
35 | {
36 | }
37 |
38 | // Destructor.
39 | ~null_event()
40 | {
41 | }
42 |
43 | // Signal the event. (Retained for backward compatibility.)
44 | template
45 | void signal(Lock&)
46 | {
47 | }
48 |
49 | // Signal all waiters.
50 | template
51 | void signal_all(Lock&)
52 | {
53 | }
54 |
55 | // Unlock the mutex and signal one waiter.
56 | template
57 | void unlock_and_signal_one(Lock&)
58 | {
59 | }
60 |
61 | // If there's a waiter, unlock the mutex and signal it.
62 | template
63 | bool maybe_unlock_and_signal_one(Lock&)
64 | {
65 | return false;
66 | }
67 |
68 | // Reset the event.
69 | template
70 | void clear(Lock&)
71 | {
72 | }
73 |
74 | // Wait for the event to become signalled.
75 | template
76 | void wait(Lock&)
77 | {
78 | }
79 | };
80 |
81 | } // namespace detail
82 | } // namespace asio
83 |
84 | #include "asio/detail/pop_options.hpp"
85 |
86 | #endif // !defined(ASIO_HAS_THREADS)
87 |
88 | #endif // ASIO_DETAIL_NULL_EVENT_HPP
89 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_fenced_block.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_fenced_block.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_FENCED_BLOCK_HPP
12 | #define ASIO_DETAIL_NULL_FENCED_BLOCK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/push_options.hpp"
19 |
20 | namespace asio {
21 | namespace detail {
22 |
23 | class null_fenced_block
24 | : private noncopyable
25 | {
26 | public:
27 | enum half_or_full_t { half, full };
28 |
29 | // Constructor.
30 | explicit null_fenced_block(half_or_full_t)
31 | {
32 | }
33 |
34 | // Destructor.
35 | ~null_fenced_block()
36 | {
37 | }
38 | };
39 |
40 | } // namespace detail
41 | } // namespace asio
42 |
43 | #include "asio/detail/pop_options.hpp"
44 |
45 | #endif // ASIO_DETAIL_NULL_FENCED_BLOCK_HPP
46 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_MUTEX_HPP
12 | #define ASIO_DETAIL_NULL_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 | #include "asio/detail/scoped_lock.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | class null_mutex
31 | : private noncopyable
32 | {
33 | public:
34 | typedef asio::detail::scoped_lock scoped_lock;
35 |
36 | // Constructor.
37 | null_mutex()
38 | {
39 | }
40 |
41 | // Destructor.
42 | ~null_mutex()
43 | {
44 | }
45 |
46 | // Lock the mutex.
47 | void lock()
48 | {
49 | }
50 |
51 | // Unlock the mutex.
52 | void unlock()
53 | {
54 | }
55 | };
56 |
57 | } // namespace detail
58 | } // namespace asio
59 |
60 | #include "asio/detail/pop_options.hpp"
61 |
62 | #endif // !defined(ASIO_HAS_THREADS)
63 |
64 | #endif // ASIO_DETAIL_NULL_MUTEX_HPP
65 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_reactor.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_reactor.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_REACTOR_HPP
12 | #define ASIO_DETAIL_NULL_REACTOR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS_RUNTIME)
21 |
22 | #include "asio/io_service.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | class null_reactor
30 | : public asio::detail::service_base
31 | {
32 | public:
33 | // Constructor.
34 | null_reactor(asio::io_service& io_service)
35 | : asio::detail::service_base(io_service)
36 | {
37 | }
38 |
39 | // Destructor.
40 | ~null_reactor()
41 | {
42 | }
43 |
44 | // Destroy all user-defined handler objects owned by the service.
45 | void shutdown_service()
46 | {
47 | }
48 |
49 | // No-op because should never be called.
50 | void run(bool /*block*/, op_queue& /*ops*/)
51 | {
52 | }
53 |
54 | // No-op.
55 | void interrupt()
56 | {
57 | }
58 | };
59 |
60 | } // namespace detail
61 | } // namespace asio
62 |
63 | #include "asio/detail/pop_options.hpp"
64 |
65 | #endif // defined(ASIO_WINDOWS_RUNTIME)
66 |
67 | #endif // ASIO_DETAIL_NULL_REACTOR_HPP
68 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_signal_blocker.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_signal_blocker.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP
12 | #define ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS) \
21 | || defined(ASIO_WINDOWS) \
22 | || defined(ASIO_WINDOWS_RUNTIME) \
23 | || defined(__CYGWIN__) \
24 | || defined(__SYMBIAN32__)
25 |
26 | #include "asio/detail/noncopyable.hpp"
27 |
28 | #include "asio/detail/push_options.hpp"
29 |
30 | namespace asio {
31 | namespace detail {
32 |
33 | class null_signal_blocker
34 | : private noncopyable
35 | {
36 | public:
37 | // Constructor blocks all signals for the calling thread.
38 | null_signal_blocker()
39 | {
40 | }
41 |
42 | // Destructor restores the previous signal mask.
43 | ~null_signal_blocker()
44 | {
45 | }
46 |
47 | // Block all signals for the calling thread.
48 | void block()
49 | {
50 | }
51 |
52 | // Restore the previous signal mask.
53 | void unblock()
54 | {
55 | }
56 | };
57 |
58 | } // namespace detail
59 | } // namespace asio
60 |
61 | #include "asio/detail/pop_options.hpp"
62 |
63 | #endif // !defined(ASIO_HAS_THREADS)
64 | // || defined(ASIO_WINDOWS)
65 | // || defined(ASIO_WINDOWS_RUNTIME)
66 | // || defined(__CYGWIN__)
67 | // || defined(__SYMBIAN32__)
68 |
69 | #endif // ASIO_DETAIL_NULL_SIGNAL_BLOCKER_HPP
70 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_static_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_static_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_STATIC_MUTEX_HPP
12 | #define ASIO_DETAIL_NULL_STATIC_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 |
22 | #include "asio/detail/scoped_lock.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | struct null_static_mutex
30 | {
31 | typedef asio::detail::scoped_lock scoped_lock;
32 |
33 | // Initialise the mutex.
34 | void init()
35 | {
36 | }
37 |
38 | // Lock the mutex.
39 | void lock()
40 | {
41 | }
42 |
43 | // Unlock the mutex.
44 | void unlock()
45 | {
46 | }
47 |
48 | int unused_;
49 | };
50 |
51 | #define ASIO_NULL_STATIC_MUTEX_INIT { 0 }
52 |
53 | } // namespace detail
54 | } // namespace asio
55 |
56 | #include "asio/detail/pop_options.hpp"
57 |
58 | #endif // !defined(ASIO_HAS_THREADS)
59 |
60 | #endif // ASIO_DETAIL_NULL_STATIC_MUTEX_HPP
61 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_thread.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_thread.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_THREAD_HPP
12 | #define ASIO_DETAIL_NULL_THREAD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 | #include "asio/detail/throw_error.hpp"
24 | #include "asio/error.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | class null_thread
32 | : private noncopyable
33 | {
34 | public:
35 | // Constructor.
36 | template
37 | null_thread(Function, unsigned int = 0)
38 | {
39 | asio::detail::throw_error(
40 | asio::error::operation_not_supported, "thread");
41 | }
42 |
43 | // Destructor.
44 | ~null_thread()
45 | {
46 | }
47 |
48 | // Wait for the thread to exit.
49 | void join()
50 | {
51 | }
52 | };
53 |
54 | } // namespace detail
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // !defined(ASIO_HAS_THREADS)
60 |
61 | #endif // ASIO_DETAIL_NULL_THREAD_HPP
62 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/null_tss_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/null_tss_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_NULL_TSS_PTR_HPP
12 | #define ASIO_DETAIL_NULL_TSS_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | template
30 | class null_tss_ptr
31 | : private noncopyable
32 | {
33 | public:
34 | // Constructor.
35 | null_tss_ptr()
36 | : value_(0)
37 | {
38 | }
39 |
40 | // Destructor.
41 | ~null_tss_ptr()
42 | {
43 | }
44 |
45 | // Get the value.
46 | operator T*() const
47 | {
48 | return value_;
49 | }
50 |
51 | // Set the value.
52 | void operator=(T* value)
53 | {
54 | value_ = value;
55 | }
56 |
57 | private:
58 | T* value_;
59 | };
60 |
61 | } // namespace detail
62 | } // namespace asio
63 |
64 | #include "asio/detail/pop_options.hpp"
65 |
66 | #endif // !defined(ASIO_HAS_THREADS)
67 |
68 | #endif // ASIO_DETAIL_NULL_TSS_PTR_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/operation.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/operation.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_OPERATION_HPP
12 | #define ASIO_DETAIL_OPERATION_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_IOCP)
21 | # include "asio/detail/win_iocp_operation.hpp"
22 | #else
23 | # include "asio/detail/task_io_service_operation.hpp"
24 | #endif
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_IOCP)
30 | typedef win_iocp_operation operation;
31 | #else
32 | typedef task_io_service_operation operation;
33 | #endif
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_OPERATION_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/posix_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/posix_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_POSIX_MUTEX_HPP
12 | #define ASIO_DETAIL_POSIX_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include
23 | #include "asio/detail/noncopyable.hpp"
24 | #include "asio/detail/scoped_lock.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | class posix_event;
32 |
33 | class posix_mutex
34 | : private noncopyable
35 | {
36 | public:
37 | typedef asio::detail::scoped_lock scoped_lock;
38 |
39 | // Constructor.
40 | ASIO_DECL posix_mutex();
41 |
42 | // Destructor.
43 | ~posix_mutex()
44 | {
45 | ::pthread_mutex_destroy(&mutex_); // Ignore EBUSY.
46 | }
47 |
48 | // Lock the mutex.
49 | void lock()
50 | {
51 | (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
52 | }
53 |
54 | // Unlock the mutex.
55 | void unlock()
56 | {
57 | (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
58 | }
59 |
60 | private:
61 | friend class posix_event;
62 | ::pthread_mutex_t mutex_;
63 | };
64 |
65 | } // namespace detail
66 | } // namespace asio
67 |
68 | #include "asio/detail/pop_options.hpp"
69 |
70 | #if defined(ASIO_HEADER_ONLY)
71 | # include "asio/detail/impl/posix_mutex.ipp"
72 | #endif // defined(ASIO_HEADER_ONLY)
73 |
74 | #endif // defined(ASIO_HAS_PTHREADS)
75 |
76 | #endif // ASIO_DETAIL_POSIX_MUTEX_HPP
77 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/posix_static_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/posix_static_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP
12 | #define ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include
23 | #include "asio/detail/scoped_lock.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | struct posix_static_mutex
31 | {
32 | typedef asio::detail::scoped_lock scoped_lock;
33 |
34 | // Initialise the mutex.
35 | void init()
36 | {
37 | // Nothing to do.
38 | }
39 |
40 | // Lock the mutex.
41 | void lock()
42 | {
43 | (void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.
44 | }
45 |
46 | // Unlock the mutex.
47 | void unlock()
48 | {
49 | (void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.
50 | }
51 |
52 | ::pthread_mutex_t mutex_;
53 | };
54 |
55 | #define ASIO_POSIX_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER }
56 |
57 | } // namespace detail
58 | } // namespace asio
59 |
60 | #include "asio/detail/pop_options.hpp"
61 |
62 | #endif // defined(ASIO_HAS_PTHREADS)
63 |
64 | #endif // ASIO_DETAIL_POSIX_STATIC_MUTEX_HPP
65 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/posix_tss_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/posix_tss_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_POSIX_TSS_PTR_HPP
12 | #define ASIO_DETAIL_POSIX_TSS_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_PTHREADS)
21 |
22 | #include
23 | #include "asio/detail/noncopyable.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | // Helper function to create thread-specific storage.
31 | ASIO_DECL void posix_tss_ptr_create(pthread_key_t& key);
32 |
33 | template
34 | class posix_tss_ptr
35 | : private noncopyable
36 | {
37 | public:
38 | // Constructor.
39 | posix_tss_ptr()
40 | {
41 | posix_tss_ptr_create(tss_key_);
42 | }
43 |
44 | // Destructor.
45 | ~posix_tss_ptr()
46 | {
47 | ::pthread_key_delete(tss_key_);
48 | }
49 |
50 | // Get the value.
51 | operator T*() const
52 | {
53 | return static_cast(::pthread_getspecific(tss_key_));
54 | }
55 |
56 | // Set the value.
57 | void operator=(T* value)
58 | {
59 | ::pthread_setspecific(tss_key_, value);
60 | }
61 |
62 | private:
63 | // Thread-specific storage to allow unlocked access to determine whether a
64 | // thread is a member of the pool.
65 | pthread_key_t tss_key_;
66 | };
67 |
68 | } // namespace detail
69 | } // namespace asio
70 |
71 | #include "asio/detail/pop_options.hpp"
72 |
73 | #if defined(ASIO_HEADER_ONLY)
74 | # include "asio/detail/impl/posix_tss_ptr.ipp"
75 | #endif // defined(ASIO_HEADER_ONLY)
76 |
77 | #endif // defined(ASIO_HAS_PTHREADS)
78 |
79 | #endif // ASIO_DETAIL_POSIX_TSS_PTR_HPP
80 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/reactor.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/reactor.hpp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_REACTOR_HPP
12 | #define ASIO_DETAIL_REACTOR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/reactor_fwd.hpp"
19 |
20 | #if defined(ASIO_HAS_EPOLL)
21 | # include "asio/detail/epoll_reactor.hpp"
22 | #elif defined(ASIO_HAS_KQUEUE)
23 | # include "asio/detail/kqueue_reactor.hpp"
24 | #elif defined(ASIO_HAS_DEV_POLL)
25 | # include "asio/detail/dev_poll_reactor.hpp"
26 | #elif defined(ASIO_WINDOWS_RUNTIME)
27 | # include "asio/detail/null_reactor.hpp"
28 | #else
29 | # include "asio/detail/select_reactor.hpp"
30 | #endif
31 |
32 | #endif // ASIO_DETAIL_REACTOR_HPP
33 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/reactor_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/reactor_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_REACTOR_FWD_HPP
12 | #define ASIO_DETAIL_REACTOR_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | namespace asio {
21 | namespace detail {
22 |
23 | #if defined(ASIO_WINDOWS_RUNTIME)
24 | typedef class null_reactor reactor;
25 | #elif defined(ASIO_HAS_IOCP)
26 | typedef class select_reactor reactor;
27 | #elif defined(ASIO_HAS_EPOLL)
28 | typedef class epoll_reactor reactor;
29 | #elif defined(ASIO_HAS_KQUEUE)
30 | typedef class kqueue_reactor reactor;
31 | #elif defined(ASIO_HAS_DEV_POLL)
32 | typedef class dev_poll_reactor reactor;
33 | #else
34 | typedef class select_reactor reactor;
35 | #endif
36 |
37 | } // namespace detail
38 | } // namespace asio
39 |
40 | #endif // ASIO_DETAIL_REACTOR_FWD_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/reactor_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/reactor_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_REACTOR_OP_HPP
12 | #define ASIO_DETAIL_REACTOR_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/operation.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | class reactor_op
27 | : public operation
28 | {
29 | public:
30 | // The error code to be passed to the completion handler.
31 | asio::error_code ec_;
32 |
33 | // The number of bytes transferred, to be passed to the completion handler.
34 | std::size_t bytes_transferred_;
35 |
36 | // Perform the operation. Returns true if it is finished.
37 | bool perform()
38 | {
39 | return perform_func_(this);
40 | }
41 |
42 | protected:
43 | typedef bool (*perform_func_type)(reactor_op*);
44 |
45 | reactor_op(perform_func_type perform_func, func_type complete_func)
46 | : operation(complete_func),
47 | bytes_transferred_(0),
48 | perform_func_(perform_func)
49 | {
50 | }
51 |
52 | private:
53 | perform_func_type perform_func_;
54 | };
55 |
56 | } // namespace detail
57 | } // namespace asio
58 |
59 | #include "asio/detail/pop_options.hpp"
60 |
61 | #endif // ASIO_DETAIL_REACTOR_OP_HPP
62 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/regex_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/regex_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_REGEX_FWD_HPP
12 | #define ASIO_DETAIL_REGEX_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #if defined(ASIO_HAS_BOOST_REGEX)
19 |
20 | #include
21 | #include
22 |
23 | namespace boost {
24 |
25 | template
26 | struct sub_match;
27 |
28 | template
29 | class match_results;
30 |
31 | } // namespace boost
32 |
33 | #endif // defined(ASIO_HAS_BOOST_REGEX)
34 |
35 | #endif // ASIO_DETAIL_REGEX_FWD_HPP
36 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/scoped_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/scoped_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SCOPED_PTR_HPP
12 | #define ASIO_DETAIL_SCOPED_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 | namespace detail {
24 |
25 | template
26 | class scoped_ptr
27 | {
28 | public:
29 | // Constructor.
30 | explicit scoped_ptr(T* p = 0)
31 | : p_(p)
32 | {
33 | }
34 |
35 | // Destructor.
36 | ~scoped_ptr()
37 | {
38 | delete p_;
39 | }
40 |
41 | // Access.
42 | T* get()
43 | {
44 | return p_;
45 | }
46 |
47 | // Access.
48 | T* operator->()
49 | {
50 | return p_;
51 | }
52 |
53 | // Dereference.
54 | T& operator*()
55 | {
56 | return *p_;
57 | }
58 |
59 | // Reset pointer.
60 | void reset(T* p = 0)
61 | {
62 | delete p_;
63 | p_ = p;
64 | }
65 |
66 | private:
67 | // Disallow copying and assignment.
68 | scoped_ptr(const scoped_ptr&);
69 | scoped_ptr& operator=(const scoped_ptr&);
70 |
71 | T* p_;
72 | };
73 |
74 | } // namespace detail
75 | } // namespace asio
76 |
77 | #include "asio/detail/pop_options.hpp"
78 |
79 | #endif // ASIO_DETAIL_SCOPED_PTR_HPP
80 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/select_interrupter.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/select_interrupter.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SELECT_INTERRUPTER_HPP
12 | #define ASIO_DETAIL_SELECT_INTERRUPTER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_WINDOWS_RUNTIME)
21 |
22 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__)
23 | # include "asio/detail/socket_select_interrupter.hpp"
24 | #elif defined(ASIO_HAS_EVENTFD)
25 | # include "asio/detail/eventfd_select_interrupter.hpp"
26 | #else
27 | # include "asio/detail/pipe_select_interrupter.hpp"
28 | #endif
29 |
30 | namespace asio {
31 | namespace detail {
32 |
33 | #if defined(ASIO_WINDOWS) || defined(__CYGWIN__) || defined(__SYMBIAN32__)
34 | typedef socket_select_interrupter select_interrupter;
35 | #elif defined(ASIO_HAS_EVENTFD)
36 | typedef eventfd_select_interrupter select_interrupter;
37 | #else
38 | typedef pipe_select_interrupter select_interrupter;
39 | #endif
40 |
41 | } // namespace detail
42 | } // namespace asio
43 |
44 | #endif // !defined(ASIO_WINDOWS_RUNTIME)
45 |
46 | #endif // ASIO_DETAIL_SELECT_INTERRUPTER_HPP
47 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/shared_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/shared_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SHARED_PTR_HPP
12 | #define ASIO_DETAIL_SHARED_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_SHARED_PTR)
21 | # include
22 | #else // defined(ASIO_HAS_STD_SHARED_PTR)
23 | # include
24 | #endif // defined(ASIO_HAS_STD_SHARED_PTR)
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_STD_SHARED_PTR)
30 | using std::shared_ptr;
31 | #else // defined(ASIO_HAS_STD_SHARED_PTR)
32 | using boost::shared_ptr;
33 | #endif // defined(ASIO_HAS_STD_SHARED_PTR)
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_SHARED_PTR_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/signal_blocker.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/signal_blocker.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SIGNAL_BLOCKER_HPP
12 | #define ASIO_DETAIL_SIGNAL_BLOCKER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS) || defined(ASIO_WINDOWS) \
21 | || defined(ASIO_WINDOWS_RUNTIME) \
22 | || defined(__CYGWIN__) || defined(__SYMBIAN32__)
23 | # include "asio/detail/null_signal_blocker.hpp"
24 | #elif defined(ASIO_HAS_PTHREADS)
25 | # include "asio/detail/posix_signal_blocker.hpp"
26 | #else
27 | # error Only Windows and POSIX are supported!
28 | #endif
29 |
30 | namespace asio {
31 | namespace detail {
32 |
33 | #if !defined(ASIO_HAS_THREADS) || defined(ASIO_WINDOWS) \
34 | || defined(ASIO_WINDOWS_RUNTIME) \
35 | || defined(__CYGWIN__) || defined(__SYMBIAN32__)
36 | typedef null_signal_blocker signal_blocker;
37 | #elif defined(ASIO_HAS_PTHREADS)
38 | typedef posix_signal_blocker signal_blocker;
39 | #endif
40 |
41 | } // namespace detail
42 | } // namespace asio
43 |
44 | #endif // ASIO_DETAIL_SIGNAL_BLOCKER_HPP
45 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/signal_init.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/signal_init.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SIGNAL_INIT_HPP
12 | #define ASIO_DETAIL_SIGNAL_INIT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_WINDOWS) && !defined(__CYGWIN__)
21 |
22 | #include
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | template
30 | class signal_init
31 | {
32 | public:
33 | // Constructor.
34 | signal_init()
35 | {
36 | std::signal(Signal, SIG_IGN);
37 | }
38 | };
39 |
40 | } // namespace detail
41 | } // namespace asio
42 |
43 | #include "asio/detail/pop_options.hpp"
44 |
45 | #endif // !defined(ASIO_WINDOWS) && !defined(__CYGWIN__)
46 |
47 | #endif // ASIO_DETAIL_SIGNAL_INIT_HPP
48 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/signal_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/signal_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SIGNAL_OP_HPP
12 | #define ASIO_DETAIL_SIGNAL_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/operation.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | class signal_op
27 | : public operation
28 | {
29 | public:
30 | // The error code to be passed to the completion handler.
31 | asio::error_code ec_;
32 |
33 | // The signal number to be passed to the completion handler.
34 | int signal_number_;
35 |
36 | protected:
37 | signal_op(func_type func)
38 | : operation(func),
39 | signal_number_(0)
40 | {
41 | }
42 | };
43 |
44 | } // namespace detail
45 | } // namespace asio
46 |
47 | #include "asio/detail/pop_options.hpp"
48 |
49 | #endif // ASIO_DETAIL_SIGNAL_OP_HPP
50 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/solaris_fenced_block.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/solaris_fenced_block.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP
12 | #define ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(__sun)
21 |
22 | #include
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | class solaris_fenced_block
30 | : private noncopyable
31 | {
32 | public:
33 | enum half_t { half };
34 | enum full_t { full };
35 |
36 | // Constructor for a half fenced block.
37 | explicit solaris_fenced_block(half_t)
38 | {
39 | }
40 |
41 | // Constructor for a full fenced block.
42 | explicit solaris_fenced_block(full_t)
43 | {
44 | membar_consumer();
45 | }
46 |
47 | // Destructor.
48 | ~solaris_fenced_block()
49 | {
50 | membar_producer();
51 | }
52 | };
53 |
54 | } // namespace detail
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // defined(__sun)
60 |
61 | #endif // ASIO_DETAIL_SOLARIS_FENCED_BLOCK_HPP
62 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/static_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/static_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_STATIC_MUTEX_HPP
12 | #define ASIO_DETAIL_STATIC_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | # include "asio/detail/null_static_mutex.hpp"
22 | #elif defined(ASIO_WINDOWS)
23 | # include "asio/detail/win_static_mutex.hpp"
24 | #elif defined(ASIO_HAS_PTHREADS)
25 | # include "asio/detail/posix_static_mutex.hpp"
26 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
27 | # include "asio/detail/std_static_mutex.hpp"
28 | #else
29 | # error Only Windows and POSIX are supported!
30 | #endif
31 |
32 | namespace asio {
33 | namespace detail {
34 |
35 | #if !defined(ASIO_HAS_THREADS)
36 | typedef null_static_mutex static_mutex;
37 | # define ASIO_STATIC_MUTEX_INIT ASIO_NULL_STATIC_MUTEX_INIT
38 | #elif defined(ASIO_WINDOWS)
39 | typedef win_static_mutex static_mutex;
40 | # define ASIO_STATIC_MUTEX_INIT ASIO_WIN_STATIC_MUTEX_INIT
41 | #elif defined(ASIO_HAS_PTHREADS)
42 | typedef posix_static_mutex static_mutex;
43 | # define ASIO_STATIC_MUTEX_INIT ASIO_POSIX_STATIC_MUTEX_INIT
44 | #elif defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
45 | typedef std_static_mutex static_mutex;
46 | # define ASIO_STATIC_MUTEX_INIT ASIO_STD_STATIC_MUTEX_INIT
47 | #endif
48 |
49 | } // namespace detail
50 | } // namespace asio
51 |
52 | #endif // ASIO_DETAIL_STATIC_MUTEX_HPP
53 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/std_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/std_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_STD_MUTEX_HPP
12 | #define ASIO_DETAIL_STD_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
21 |
22 | #include
23 | #include "asio/detail/noncopyable.hpp"
24 | #include "asio/detail/scoped_lock.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | class std_event;
32 |
33 | class std_mutex
34 | : private noncopyable
35 | {
36 | public:
37 | typedef asio::detail::scoped_lock scoped_lock;
38 |
39 | // Constructor.
40 | std_mutex()
41 | {
42 | }
43 |
44 | // Destructor.
45 | ~std_mutex()
46 | {
47 | }
48 |
49 | // Lock the mutex.
50 | void lock()
51 | {
52 | mutex_.lock();
53 | }
54 |
55 | // Unlock the mutex.
56 | void unlock()
57 | {
58 | mutex_.unlock();
59 | }
60 |
61 | private:
62 | friend class std_event;
63 | std::mutex mutex_;
64 | };
65 |
66 | } // namespace detail
67 | } // namespace asio
68 |
69 | #include "asio/detail/pop_options.hpp"
70 |
71 | #endif // defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
72 |
73 | #endif // ASIO_DETAIL_STD_MUTEX_HPP
74 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/std_static_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/std_static_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_STD_STATIC_MUTEX_HPP
12 | #define ASIO_DETAIL_STD_STATIC_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
21 |
22 | #include
23 | #include "asio/detail/noncopyable.hpp"
24 | #include "asio/detail/scoped_lock.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | class std_event;
32 |
33 | class std_static_mutex
34 | : private noncopyable
35 | {
36 | public:
37 | typedef asio::detail::scoped_lock scoped_lock;
38 |
39 | // Constructor.
40 | std_static_mutex(int)
41 | {
42 | }
43 |
44 | // Destructor.
45 | ~std_static_mutex()
46 | {
47 | }
48 |
49 | // Initialise the mutex.
50 | void init()
51 | {
52 | // Nothing to do.
53 | }
54 |
55 | // Lock the mutex.
56 | void lock()
57 | {
58 | mutex_.lock();
59 | }
60 |
61 | // Unlock the mutex.
62 | void unlock()
63 | {
64 | mutex_.unlock();
65 | }
66 |
67 | private:
68 | friend class std_event;
69 | std::mutex mutex_;
70 | };
71 |
72 | #define ASIO_STD_STATIC_MUTEX_INIT 0
73 |
74 | } // namespace detail
75 | } // namespace asio
76 |
77 | #include "asio/detail/pop_options.hpp"
78 |
79 | #endif // defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
80 |
81 | #endif // ASIO_DETAIL_STD_STATIC_MUTEX_HPP
82 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/std_thread.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/std_thread.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_STD_THREAD_HPP
12 | #define ASIO_DETAIL_STD_THREAD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_THREAD)
21 |
22 | #include
23 | #include "asio/detail/noncopyable.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | class std_thread
31 | : private noncopyable
32 | {
33 | public:
34 | // Constructor.
35 | template
36 | std_thread(Function f, unsigned int = 0)
37 | : thread_(f)
38 | {
39 | }
40 |
41 | // Destructor.
42 | ~std_thread()
43 | {
44 | join();
45 | }
46 |
47 | // Wait for the thread to exit.
48 | void join()
49 | {
50 | if (thread_.joinable())
51 | thread_.join();
52 | }
53 |
54 | private:
55 | std::thread thread_;
56 | };
57 |
58 | } // namespace detail
59 | } // namespace asio
60 |
61 | #include "asio/detail/pop_options.hpp"
62 |
63 | #endif // defined(ASIO_HAS_STD_THREAD)
64 |
65 | #endif // ASIO_DETAIL_STD_THREAD_HPP
66 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/task_io_service_thread_info.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/task_io_service_thread_info.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP
12 | #define ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/op_queue.hpp"
19 | #include "asio/detail/thread_info_base.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | class task_io_service;
27 | class task_io_service_operation;
28 |
29 | struct task_io_service_thread_info : public thread_info_base
30 | {
31 | op_queue private_op_queue;
32 | long private_outstanding_work;
33 | };
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #include "asio/detail/pop_options.hpp"
39 |
40 | #endif // ASIO_DETAIL_TASK_IO_SERVICE_THREAD_INFO_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/thread.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/thread.hpp
3 | // ~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_THREAD_HPP
12 | #define ASIO_DETAIL_THREAD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | # include "asio/detail/null_thread.hpp"
22 | #elif defined(ASIO_WINDOWS)
23 | # if defined(UNDER_CE)
24 | # include "asio/detail/wince_thread.hpp"
25 | # else
26 | # include "asio/detail/win_thread.hpp"
27 | # endif
28 | #elif defined(ASIO_HAS_PTHREADS)
29 | # include "asio/detail/posix_thread.hpp"
30 | #elif defined(ASIO_HAS_STD_THREAD)
31 | # include "asio/detail/std_thread.hpp"
32 | #else
33 | # error Only Windows, POSIX and std::thread are supported!
34 | #endif
35 |
36 | namespace asio {
37 | namespace detail {
38 |
39 | #if !defined(ASIO_HAS_THREADS)
40 | typedef null_thread thread;
41 | #elif defined(ASIO_WINDOWS)
42 | # if defined(UNDER_CE)
43 | typedef wince_thread thread;
44 | # else
45 | typedef win_thread thread;
46 | # endif
47 | #elif defined(ASIO_HAS_PTHREADS)
48 | typedef posix_thread thread;
49 | #elif defined(ASIO_HAS_STD_THREAD)
50 | typedef std_thread thread;
51 | #endif
52 |
53 | } // namespace detail
54 | } // namespace asio
55 |
56 | #endif // ASIO_DETAIL_THREAD_HPP
57 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/throw_error.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/throw_error.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_THROW_ERROR_HPP
12 | #define ASIO_DETAIL_THROW_ERROR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/error_code.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | ASIO_DECL void do_throw_error(const asio::error_code& err);
27 |
28 | ASIO_DECL void do_throw_error(const asio::error_code& err,
29 | const char* location);
30 |
31 | inline void throw_error(const asio::error_code& err)
32 | {
33 | if (err)
34 | do_throw_error(err);
35 | }
36 |
37 | inline void throw_error(const asio::error_code& err,
38 | const char* location)
39 | {
40 | if (err)
41 | do_throw_error(err, location);
42 | }
43 |
44 | } // namespace detail
45 | } // namespace asio
46 |
47 | #include "asio/detail/pop_options.hpp"
48 |
49 | #if defined(ASIO_HEADER_ONLY)
50 | # include "asio/detail/impl/throw_error.ipp"
51 | #endif // defined(ASIO_HEADER_ONLY)
52 |
53 | #endif // ASIO_DETAIL_THROW_ERROR_HPP
54 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/throw_exception.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/throw_exception.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_THROW_EXCEPTION_HPP
12 | #define ASIO_DETAIL_THROW_EXCEPTION_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
21 | # include
22 | #endif // defined(ASIO_BOOST_THROW_EXCEPTION)
23 |
24 | namespace asio {
25 | namespace detail {
26 |
27 | #if defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
28 | using boost::throw_exception;
29 | #else // defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
30 |
31 | // Declare the throw_exception function for all targets.
32 | template
33 | void throw_exception(const Exception& e);
34 |
35 | // Only define the throw_exception function when exceptions are enabled.
36 | // Otherwise, it is up to the application to provide a definition of this
37 | // function.
38 | # if !defined(ASIO_NO_EXCEPTIONS)
39 | template
40 | void throw_exception(const Exception& e)
41 | {
42 | throw e;
43 | }
44 | # endif // !defined(ASIO_NO_EXCEPTIONS)
45 |
46 | #endif // defined(ASIO_HAS_BOOST_THROW_EXCEPTION)
47 |
48 | } // namespace detail
49 | } // namespace asio
50 |
51 | #endif // ASIO_DETAIL_THROW_EXCEPTION_HPP
52 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/timer_queue_base.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/timer_queue_base.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TIMER_QUEUE_BASE_HPP
12 | #define ASIO_DETAIL_TIMER_QUEUE_BASE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/noncopyable.hpp"
20 | #include "asio/detail/op_queue.hpp"
21 | #include "asio/detail/operation.hpp"
22 |
23 | #include "asio/detail/push_options.hpp"
24 |
25 | namespace asio {
26 | namespace detail {
27 |
28 | class timer_queue_base
29 | : private noncopyable
30 | {
31 | public:
32 | // Constructor.
33 | timer_queue_base() : next_(0) {}
34 |
35 | // Destructor.
36 | virtual ~timer_queue_base() {}
37 |
38 | // Whether there are no timers in the queue.
39 | virtual bool empty() const = 0;
40 |
41 | // Get the time to wait until the next timer.
42 | virtual long wait_duration_msec(long max_duration) const = 0;
43 |
44 | // Get the time to wait until the next timer.
45 | virtual long wait_duration_usec(long max_duration) const = 0;
46 |
47 | // Dequeue all ready timers.
48 | virtual void get_ready_timers(op_queue& ops) = 0;
49 |
50 | // Dequeue all timers.
51 | virtual void get_all_timers(op_queue& ops) = 0;
52 |
53 | private:
54 | friend class timer_queue_set;
55 |
56 | // Next timer queue in the set.
57 | timer_queue_base* next_;
58 | };
59 |
60 | template
61 | class timer_queue;
62 |
63 | } // namespace detail
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #endif // ASIO_DETAIL_TIMER_QUEUE_BASE_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/timer_queue_set.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/timer_queue_set.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TIMER_QUEUE_SET_HPP
12 | #define ASIO_DETAIL_TIMER_QUEUE_SET_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/timer_queue_base.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | class timer_queue_set
27 | {
28 | public:
29 | // Constructor.
30 | ASIO_DECL timer_queue_set();
31 |
32 | // Add a timer queue to the set.
33 | ASIO_DECL void insert(timer_queue_base* q);
34 |
35 | // Remove a timer queue from the set.
36 | ASIO_DECL void erase(timer_queue_base* q);
37 |
38 | // Determine whether all queues are empty.
39 | ASIO_DECL bool all_empty() const;
40 |
41 | // Get the wait duration in milliseconds.
42 | ASIO_DECL long wait_duration_msec(long max_duration) const;
43 |
44 | // Get the wait duration in microseconds.
45 | ASIO_DECL long wait_duration_usec(long max_duration) const;
46 |
47 | // Dequeue all ready timers.
48 | ASIO_DECL void get_ready_timers(op_queue& ops);
49 |
50 | // Dequeue all timers.
51 | ASIO_DECL void get_all_timers(op_queue& ops);
52 |
53 | private:
54 | timer_queue_base* first_;
55 | };
56 |
57 | } // namespace detail
58 | } // namespace asio
59 |
60 | #include "asio/detail/pop_options.hpp"
61 |
62 | #if defined(ASIO_HEADER_ONLY)
63 | # include "asio/detail/impl/timer_queue_set.ipp"
64 | #endif // defined(ASIO_HEADER_ONLY)
65 |
66 | #endif // ASIO_DETAIL_TIMER_QUEUE_SET_HPP
67 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/timer_scheduler.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/timer_scheduler.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TIMER_SCHEDULER_HPP
12 | #define ASIO_DETAIL_TIMER_SCHEDULER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/timer_scheduler_fwd.hpp"
20 |
21 | #if defined(ASIO_WINDOWS_RUNTIME)
22 | # include "asio/detail/winrt_timer_scheduler.hpp"
23 | #elif defined(ASIO_HAS_IOCP)
24 | # include "asio/detail/win_iocp_io_service.hpp"
25 | #elif defined(ASIO_HAS_EPOLL)
26 | # include "asio/detail/epoll_reactor.hpp"
27 | #elif defined(ASIO_HAS_KQUEUE)
28 | # include "asio/detail/kqueue_reactor.hpp"
29 | #elif defined(ASIO_HAS_DEV_POLL)
30 | # include "asio/detail/dev_poll_reactor.hpp"
31 | #else
32 | # include "asio/detail/select_reactor.hpp"
33 | #endif
34 |
35 | #endif // ASIO_DETAIL_TIMER_SCHEDULER_HPP
36 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/timer_scheduler_fwd.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/timer_scheduler_fwd.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP
12 | #define ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | namespace asio {
21 | namespace detail {
22 |
23 | #if defined(ASIO_WINDOWS_RUNTIME)
24 | typedef class winrt_timer_scheduler timer_scheduler;
25 | #elif defined(ASIO_HAS_IOCP)
26 | typedef class win_iocp_io_service timer_scheduler;
27 | #elif defined(ASIO_HAS_EPOLL)
28 | typedef class epoll_reactor timer_scheduler;
29 | #elif defined(ASIO_HAS_KQUEUE)
30 | typedef class kqueue_reactor timer_scheduler;
31 | #elif defined(ASIO_HAS_DEV_POLL)
32 | typedef class dev_poll_reactor timer_scheduler;
33 | #else
34 | typedef class select_reactor timer_scheduler;
35 | #endif
36 |
37 | } // namespace detail
38 | } // namespace asio
39 |
40 | #endif // ASIO_DETAIL_TIMER_SCHEDULER_FWD_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/tss_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/tss_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TSS_PTR_HPP
12 | #define ASIO_DETAIL_TSS_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_HAS_THREADS)
21 | # include "asio/detail/null_tss_ptr.hpp"
22 | #elif defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
23 | # include "asio/detail/keyword_tss_ptr.hpp"
24 | #elif defined(ASIO_WINDOWS)
25 | # include "asio/detail/win_tss_ptr.hpp"
26 | #elif defined(ASIO_HAS_PTHREADS)
27 | # include "asio/detail/posix_tss_ptr.hpp"
28 | #else
29 | # error Only Windows and POSIX are supported!
30 | #endif
31 |
32 | #include "asio/detail/push_options.hpp"
33 |
34 | namespace asio {
35 | namespace detail {
36 |
37 | template
38 | class tss_ptr
39 | #if !defined(ASIO_HAS_THREADS)
40 | : public null_tss_ptr
41 | #elif defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
42 | : public keyword_tss_ptr
43 | #elif defined(ASIO_WINDOWS)
44 | : public win_tss_ptr
45 | #elif defined(ASIO_HAS_PTHREADS)
46 | : public posix_tss_ptr
47 | #endif
48 | {
49 | public:
50 | void operator=(T* value)
51 | {
52 | #if !defined(ASIO_HAS_THREADS)
53 | null_tss_ptr::operator=(value);
54 | #elif defined(ASIO_HAS_THREAD_KEYWORD_EXTENSION)
55 | keyword_tss_ptr::operator=(value);
56 | #elif defined(ASIO_WINDOWS)
57 | win_tss_ptr::operator=(value);
58 | #elif defined(ASIO_HAS_PTHREADS)
59 | posix_tss_ptr::operator=(value);
60 | #endif
61 | }
62 | };
63 |
64 | } // namespace detail
65 | } // namespace asio
66 |
67 | #include "asio/detail/pop_options.hpp"
68 |
69 | #endif // ASIO_DETAIL_TSS_PTR_HPP
70 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/type_traits.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/type_traits.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_TYPE_TRAITS_HPP
12 | #define ASIO_DETAIL_TYPE_TRAITS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_TYPE_TRAITS)
21 | # include
22 | #else // defined(ASIO_HAS_TYPE_TRAITS)
23 | # include
24 | # include
25 | # include
26 | # include
27 | # include
28 | # include
29 | # include
30 | # include
31 | #endif // defined(ASIO_HAS_TYPE_TRAITS)
32 |
33 | namespace asio {
34 |
35 | #if defined(ASIO_HAS_STD_TYPE_TRAITS)
36 | using std::add_const;
37 | using std::enable_if;
38 | using std::is_const;
39 | using std::is_convertible;
40 | using std::is_function;
41 | using std::is_same;
42 | using std::remove_pointer;
43 | using std::remove_reference;
44 | #else // defined(ASIO_HAS_STD_TYPE_TRAITS)
45 | using boost::add_const;
46 | template
47 | struct enable_if : boost::enable_if_c {};
48 | using boost::is_const;
49 | using boost::is_convertible;
50 | using boost::is_function;
51 | using boost::is_same;
52 | using boost::remove_pointer;
53 | using boost::remove_reference;
54 | #endif // defined(ASIO_HAS_STD_TYPE_TRAITS)
55 |
56 | } // namespace asio
57 |
58 | #endif // ASIO_DETAIL_TYPE_TRAITS_HPP
59 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/wait_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/wait_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WAIT_OP_HPP
12 | #define ASIO_DETAIL_WAIT_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/operation.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | class wait_op
27 | : public operation
28 | {
29 | public:
30 | // The error code to be passed to the completion handler.
31 | asio::error_code ec_;
32 |
33 | protected:
34 | wait_op(func_type func)
35 | : operation(func)
36 | {
37 | }
38 | };
39 |
40 | } // namespace detail
41 | } // namespace asio
42 |
43 | #include "asio/detail/pop_options.hpp"
44 |
45 | #endif // ASIO_DETAIL_WAIT_OP_HPP
46 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/weak_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/weak_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WEAK_PTR_HPP
12 | #define ASIO_DETAIL_WEAK_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_SHARED_PTR)
21 | # include
22 | #else // defined(ASIO_HAS_STD_SHARED_PTR)
23 | # include
24 | #endif // defined(ASIO_HAS_STD_SHARED_PTR)
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | #if defined(ASIO_HAS_STD_SHARED_PTR)
30 | using std::weak_ptr;
31 | #else // defined(ASIO_HAS_STD_SHARED_PTR)
32 | using boost::weak_ptr;
33 | #endif // defined(ASIO_HAS_STD_SHARED_PTR)
34 |
35 | } // namespace detail
36 | } // namespace asio
37 |
38 | #endif // ASIO_DETAIL_WEAK_PTR_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/win_iocp_thread_info.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/win_iocp_thread_info.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP
12 | #define ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/thread_info_base.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 | namespace detail {
24 |
25 | struct win_iocp_thread_info : public thread_info_base
26 | {
27 | };
28 |
29 | } // namespace detail
30 | } // namespace asio
31 |
32 | #include "asio/detail/pop_options.hpp"
33 |
34 | #endif // ASIO_DETAIL_WIN_IOCP_THREAD_INFO_HPP
35 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/win_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/win_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WIN_MUTEX_HPP
12 | #define ASIO_DETAIL_WIN_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 | #include "asio/detail/scoped_lock.hpp"
24 | #include "asio/detail/socket_types.hpp"
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace detail {
30 |
31 | class win_mutex
32 | : private noncopyable
33 | {
34 | public:
35 | typedef asio::detail::scoped_lock scoped_lock;
36 |
37 | // Constructor.
38 | ASIO_DECL win_mutex();
39 |
40 | // Destructor.
41 | ~win_mutex()
42 | {
43 | ::DeleteCriticalSection(&crit_section_);
44 | }
45 |
46 | // Lock the mutex.
47 | void lock()
48 | {
49 | ::EnterCriticalSection(&crit_section_);
50 | }
51 |
52 | // Unlock the mutex.
53 | void unlock()
54 | {
55 | ::LeaveCriticalSection(&crit_section_);
56 | }
57 |
58 | private:
59 | // Initialisation must be performed in a separate function to the constructor
60 | // since the compiler does not support the use of structured exceptions and
61 | // C++ exceptions in the same function.
62 | ASIO_DECL int do_init();
63 |
64 | ::CRITICAL_SECTION crit_section_;
65 | };
66 |
67 | } // namespace detail
68 | } // namespace asio
69 |
70 | #include "asio/detail/pop_options.hpp"
71 |
72 | #if defined(ASIO_HEADER_ONLY)
73 | # include "asio/detail/impl/win_mutex.ipp"
74 | #endif // defined(ASIO_HEADER_ONLY)
75 |
76 | #endif // defined(ASIO_WINDOWS)
77 |
78 | #endif // ASIO_DETAIL_WIN_MUTEX_HPP
79 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/win_static_mutex.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/win_static_mutex.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WIN_STATIC_MUTEX_HPP
12 | #define ASIO_DETAIL_WIN_STATIC_MUTEX_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS)
21 |
22 | #include "asio/detail/scoped_lock.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace detail {
28 |
29 | struct win_static_mutex
30 | {
31 | typedef asio::detail::scoped_lock scoped_lock;
32 |
33 | // Initialise the mutex.
34 | ASIO_DECL void init();
35 |
36 | // Initialisation must be performed in a separate function to the "public"
37 | // init() function since the compiler does not support the use of structured
38 | // exceptions and C++ exceptions in the same function.
39 | ASIO_DECL int do_init();
40 |
41 | // Lock the mutex.
42 | void lock()
43 | {
44 | ::EnterCriticalSection(&crit_section_);
45 | }
46 |
47 | // Unlock the mutex.
48 | void unlock()
49 | {
50 | ::LeaveCriticalSection(&crit_section_);
51 | }
52 |
53 | bool initialised_;
54 | ::CRITICAL_SECTION crit_section_;
55 | };
56 |
57 | #if defined(UNDER_CE)
58 | # define ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0 } }
59 | #else // defined(UNDER_CE)
60 | # define ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0, 0 } }
61 | #endif // defined(UNDER_CE)
62 |
63 | } // namespace detail
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #if defined(ASIO_HEADER_ONLY)
69 | # include "asio/detail/impl/win_static_mutex.ipp"
70 | #endif // defined(ASIO_HEADER_ONLY)
71 |
72 | #endif // defined(ASIO_WINDOWS)
73 |
74 | #endif // ASIO_DETAIL_WIN_STATIC_MUTEX_HPP
75 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/win_tss_ptr.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/win_tss_ptr.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WIN_TSS_PTR_HPP
12 | #define ASIO_DETAIL_WIN_TSS_PTR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_WINDOWS)
21 |
22 | #include "asio/detail/noncopyable.hpp"
23 | #include "asio/detail/socket_types.hpp"
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace detail {
29 |
30 | // Helper function to create thread-specific storage.
31 | ASIO_DECL DWORD win_tss_ptr_create();
32 |
33 | template
34 | class win_tss_ptr
35 | : private noncopyable
36 | {
37 | public:
38 | // Constructor.
39 | win_tss_ptr()
40 | : tss_key_(win_tss_ptr_create())
41 | {
42 | }
43 |
44 | // Destructor.
45 | ~win_tss_ptr()
46 | {
47 | ::TlsFree(tss_key_);
48 | }
49 |
50 | // Get the value.
51 | operator T*() const
52 | {
53 | return static_cast(::TlsGetValue(tss_key_));
54 | }
55 |
56 | // Set the value.
57 | void operator=(T* value)
58 | {
59 | ::TlsSetValue(tss_key_, value);
60 | }
61 |
62 | private:
63 | // Thread-specific storage to allow unlocked access to determine whether a
64 | // thread is a member of the pool.
65 | DWORD tss_key_;
66 | };
67 |
68 | } // namespace detail
69 | } // namespace asio
70 |
71 | #include "asio/detail/pop_options.hpp"
72 |
73 | #if defined(ASIO_HEADER_ONLY)
74 | # include "asio/detail/impl/win_tss_ptr.ipp"
75 | #endif // defined(ASIO_HEADER_ONLY)
76 |
77 | #endif // defined(ASIO_WINDOWS)
78 |
79 | #endif // ASIO_DETAIL_WIN_TSS_PTR_HPP
80 |
--------------------------------------------------------------------------------
/src/include_asio/asio/detail/winrt_async_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // detail/winrt_async_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_DETAIL_WINRT_ASYNC_OP_HPP
12 | #define ASIO_DETAIL_WINRT_ASYNC_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/operation.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace detail {
25 |
26 | template
27 | class winrt_async_op
28 | : public operation
29 | {
30 | public:
31 | // The error code to be passed to the completion handler.
32 | asio::error_code ec_;
33 |
34 | // The result of the operation, to be passed to the completion handler.
35 | TResult result_;
36 |
37 | protected:
38 | winrt_async_op(func_type complete_func)
39 | : operation(complete_func),
40 | result_()
41 | {
42 | }
43 | };
44 |
45 | template <>
46 | class winrt_async_op
47 | : public operation
48 | {
49 | public:
50 | // The error code to be passed to the completion handler.
51 | asio::error_code ec_;
52 |
53 | protected:
54 | winrt_async_op(func_type complete_func)
55 | : operation(complete_func)
56 | {
57 | }
58 | };
59 |
60 | } // namespace detail
61 | } // namespace asio
62 |
63 | #include "asio/detail/pop_options.hpp"
64 |
65 | #endif // ASIO_DETAIL_WINRT_ASYNC_OP_HPP
66 |
--------------------------------------------------------------------------------
/src/include_asio/asio/handler_continuation_hook.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // handler_continuation_hook.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_HANDLER_CONTINUATION_HOOK_HPP
12 | #define ASIO_HANDLER_CONTINUATION_HOOK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 |
24 | /// Default continuation function for handlers.
25 | /**
26 | * Asynchronous operations may represent a continuation of the asynchronous
27 | * control flow associated with the current handler. The implementation can use
28 | * this knowledge to optimise scheduling of the handler.
29 | *
30 | * Implement asio_handler_is_continuation for your own handlers to indicate
31 | * when a handler represents a continuation.
32 | *
33 | * The default implementation of the continuation hook returns false.
34 | *
35 | * @par Example
36 | * @code
37 | * class my_handler;
38 | *
39 | * bool asio_handler_is_continuation(my_handler* context)
40 | * {
41 | * return true;
42 | * }
43 | * @endcode
44 | */
45 | inline bool asio_handler_is_continuation(...)
46 | {
47 | return false;
48 | }
49 |
50 | } // namespace asio
51 |
52 | #include "asio/detail/pop_options.hpp"
53 |
54 | #endif // ASIO_HANDLER_CONTINUATION_HOOK_HPP
55 |
--------------------------------------------------------------------------------
/src/include_asio/asio/high_resolution_timer.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // high_resolution_timer.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_HIGH_RESOLUTION_TIMER_HPP
12 | #define ASIO_HIGH_RESOLUTION_TIMER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_CHRONO) \
21 | || defined(ASIO_HAS_BOOST_CHRONO) \
22 | || defined(GENERATING_DOCUMENTATION)
23 |
24 | #if defined(ASIO_HAS_STD_CHRONO)
25 | # include
26 | #elif defined(ASIO_HAS_BOOST_CHRONO)
27 | # include
28 | #endif
29 |
30 | #include "asio/basic_waitable_timer.hpp"
31 |
32 | namespace asio {
33 |
34 | #if defined(GENERATING_DOCUMENTATION)
35 | /// Typedef for a timer based on the high resolution clock.
36 | /**
37 | * This typedef uses the C++11 @c <chrono> standard library facility, if
38 | * available. Otherwise, it may use the Boost.Chrono library. To explicitly
39 | * utilise Boost.Chrono, use the basic_waitable_timer template directly:
40 | * @code
41 | * typedef basic_waitable_timer timer;
42 | * @endcode
43 | */
44 | typedef basic_waitable_timer<
45 | chrono::high_resolution_clock>
46 | high_resolution_timer;
47 | #elif defined(ASIO_HAS_STD_CHRONO)
48 | typedef basic_waitable_timer<
49 | std::chrono::high_resolution_clock>
50 | high_resolution_timer;
51 | #elif defined(ASIO_HAS_BOOST_CHRONO)
52 | typedef basic_waitable_timer<
53 | boost::chrono::high_resolution_clock>
54 | high_resolution_timer;
55 | #endif
56 |
57 | } // namespace asio
58 |
59 | #endif // defined(ASIO_HAS_STD_CHRONO)
60 | // || defined(ASIO_HAS_BOOST_CHRONO)
61 | // || defined(GENERATING_DOCUMENTATION)
62 |
63 | #endif // ASIO_HIGH_RESOLUTION_TIMER_HPP
64 |
--------------------------------------------------------------------------------
/src/include_asio/asio/impl/serial_port_base.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // impl/serial_port_base.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
7 | //
8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 | //
11 |
12 | #ifndef ASIO_IMPL_SERIAL_PORT_BASE_HPP
13 | #define ASIO_IMPL_SERIAL_PORT_BASE_HPP
14 |
15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 | # pragma once
17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 |
19 | #include "asio/detail/push_options.hpp"
20 |
21 | namespace asio {
22 |
23 | inline serial_port_base::baud_rate::baud_rate(unsigned int rate)
24 | : value_(rate)
25 | {
26 | }
27 |
28 | inline unsigned int serial_port_base::baud_rate::value() const
29 | {
30 | return value_;
31 | }
32 |
33 | inline serial_port_base::flow_control::type
34 | serial_port_base::flow_control::value() const
35 | {
36 | return value_;
37 | }
38 |
39 | inline serial_port_base::parity::type serial_port_base::parity::value() const
40 | {
41 | return value_;
42 | }
43 |
44 | inline serial_port_base::stop_bits::type
45 | serial_port_base::stop_bits::value() const
46 | {
47 | return value_;
48 | }
49 |
50 | inline unsigned int serial_port_base::character_size::value() const
51 | {
52 | return value_;
53 | }
54 |
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // ASIO_IMPL_SERIAL_PORT_BASE_HPP
60 |
--------------------------------------------------------------------------------
/src/include_asio/asio/impl/src.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // impl/src.cpp
3 | // ~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #if defined(_MSC_VER) \
12 | || defined(__BORLANDC__) \
13 | || defined(__DMC__)
14 | # pragma message ( \
15 | "This file is deprecated. " \
16 | "Please #include instead.")
17 | #elif defined(__GNUC__) \
18 | || defined(__HP_aCC) \
19 | || defined(__SUNPRO_CC) \
20 | || defined(__IBMCPP__)
21 | # warning "This file is deprecated."
22 | # warning "Please #include instead."
23 | #endif
24 |
25 | #include "asio/impl/src.hpp"
26 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/host_name.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/host_name.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_HOST_NAME_HPP
12 | #define ASIO_IP_HOST_NAME_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include
20 | #include "asio/error_code.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 |
27 | /// Get the current host name.
28 | ASIO_DECL std::string host_name();
29 |
30 | /// Get the current host name.
31 | ASIO_DECL std::string host_name(asio::error_code& ec);
32 |
33 | } // namespace ip
34 | } // namespace asio
35 |
36 | #include "asio/detail/pop_options.hpp"
37 |
38 | #if defined(ASIO_HEADER_ONLY)
39 | # include "asio/ip/impl/host_name.ipp"
40 | #endif // defined(ASIO_HEADER_ONLY)
41 |
42 | #endif // ASIO_IP_HOST_NAME_HPP
43 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/impl/address.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/impl/address.hpp
3 | // ~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_IMPL_ADDRESS_HPP
12 | #define ASIO_IP_IMPL_ADDRESS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #if !defined(ASIO_NO_IOSTREAM)
19 |
20 | #include "asio/detail/throw_error.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 |
27 | template
28 | std::basic_ostream& operator<<(
29 | std::basic_ostream& os, const address& addr)
30 | {
31 | asio::error_code ec;
32 | std::string s = addr.to_string(ec);
33 | if (ec)
34 | {
35 | if (os.exceptions() & std::basic_ostream::failbit)
36 | asio::detail::throw_error(ec);
37 | else
38 | os.setstate(std::basic_ostream::failbit);
39 | }
40 | else
41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i)
42 | os << os.widen(*i);
43 | return os;
44 | }
45 |
46 | } // namespace ip
47 | } // namespace asio
48 |
49 | #include "asio/detail/pop_options.hpp"
50 |
51 | #endif // !defined(ASIO_NO_IOSTREAM)
52 |
53 | #endif // ASIO_IP_IMPL_ADDRESS_HPP
54 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/impl/address_v4.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/impl/address_v4.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_IMPL_ADDRESS_V4_HPP
12 | #define ASIO_IP_IMPL_ADDRESS_V4_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #if !defined(ASIO_NO_IOSTREAM)
19 |
20 | #include "asio/detail/throw_error.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 |
27 | template
28 | std::basic_ostream& operator<<(
29 | std::basic_ostream& os, const address_v4& addr)
30 | {
31 | asio::error_code ec;
32 | std::string s = addr.to_string(ec);
33 | if (ec)
34 | {
35 | if (os.exceptions() & std::basic_ostream::failbit)
36 | asio::detail::throw_error(ec);
37 | else
38 | os.setstate(std::basic_ostream::failbit);
39 | }
40 | else
41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i)
42 | os << os.widen(*i);
43 | return os;
44 | }
45 |
46 | } // namespace ip
47 | } // namespace asio
48 |
49 | #include "asio/detail/pop_options.hpp"
50 |
51 | #endif // !defined(ASIO_NO_IOSTREAM)
52 |
53 | #endif // ASIO_IP_IMPL_ADDRESS_V4_HPP
54 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/impl/address_v6.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/impl/address_v6.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_IMPL_ADDRESS_V6_HPP
12 | #define ASIO_IP_IMPL_ADDRESS_V6_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #if !defined(ASIO_NO_IOSTREAM)
19 |
20 | #include "asio/detail/throw_error.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 |
27 | template
28 | std::basic_ostream& operator<<(
29 | std::basic_ostream& os, const address_v6& addr)
30 | {
31 | asio::error_code ec;
32 | std::string s = addr.to_string(ec);
33 | if (ec)
34 | {
35 | if (os.exceptions() & std::basic_ostream::failbit)
36 | asio::detail::throw_error(ec);
37 | else
38 | os.setstate(std::basic_ostream::failbit);
39 | }
40 | else
41 | for (std::string::iterator i = s.begin(); i != s.end(); ++i)
42 | os << os.widen(*i);
43 | return os;
44 | }
45 |
46 | } // namespace ip
47 | } // namespace asio
48 |
49 | #include "asio/detail/pop_options.hpp"
50 |
51 | #endif // !defined(ASIO_NO_IOSTREAM)
52 |
53 | #endif // ASIO_IP_IMPL_ADDRESS_V6_HPP
54 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/impl/basic_endpoint.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/impl/basic_endpoint.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
12 | #define ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #if !defined(ASIO_NO_IOSTREAM)
19 |
20 | #include "asio/detail/throw_error.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 |
27 | template
28 | std::basic_ostream& operator<<(
29 | std::basic_ostream& os,
30 | const basic_endpoint& endpoint)
31 | {
32 | asio::ip::detail::endpoint tmp_ep(endpoint.address(), endpoint.port());
33 | asio::error_code ec;
34 | std::string s = tmp_ep.to_string(ec);
35 | if (ec)
36 | {
37 | if (os.exceptions() & std::basic_ostream::failbit)
38 | asio::detail::throw_error(ec);
39 | else
40 | os.setstate(std::basic_ostream::failbit);
41 | }
42 | else
43 | for (std::string::iterator i = s.begin(); i != s.end(); ++i)
44 | os << os.widen(*i);
45 | return os;
46 | }
47 |
48 | } // namespace ip
49 | } // namespace asio
50 |
51 | #include "asio/detail/pop_options.hpp"
52 |
53 | #endif // !defined(ASIO_NO_IOSTREAM)
54 |
55 | #endif // ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
56 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/impl/host_name.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/impl/host_name.ipp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_IMPL_HOST_NAME_IPP
12 | #define ASIO_IP_IMPL_HOST_NAME_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/socket_ops.hpp"
20 | #include "asio/detail/throw_error.hpp"
21 | #include "asio/detail/winsock_init.hpp"
22 | #include "asio/ip/host_name.hpp"
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ip {
28 |
29 | std::string host_name()
30 | {
31 | char name[1024];
32 | asio::error_code ec;
33 | if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
34 | {
35 | asio::detail::throw_error(ec);
36 | return std::string();
37 | }
38 | return std::string(name);
39 | }
40 |
41 | std::string host_name(asio::error_code& ec)
42 | {
43 | char name[1024];
44 | if (asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
45 | return std::string();
46 | return std::string(name);
47 | }
48 |
49 | } // namespace ip
50 | } // namespace asio
51 |
52 | #include "asio/detail/pop_options.hpp"
53 |
54 | #endif // ASIO_IP_IMPL_HOST_NAME_IPP
55 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/unicast.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/unicast.hpp
3 | // ~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_UNICAST_HPP
12 | #define ASIO_IP_UNICAST_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include
20 | #include "asio/ip/detail/socket_option.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace ip {
26 | namespace unicast {
27 |
28 | /// Socket option for time-to-live associated with outgoing unicast packets.
29 | /**
30 | * Implements the IPPROTO_IP/IP_UNICAST_TTL socket option.
31 | *
32 | * @par Examples
33 | * Setting the option:
34 | * @code
35 | * asio::ip::udp::socket socket(io_service);
36 | * ...
37 | * asio::ip::unicast::hops option(4);
38 | * socket.set_option(option);
39 | * @endcode
40 | *
41 | * @par
42 | * Getting the current option value:
43 | * @code
44 | * asio::ip::udp::socket socket(io_service);
45 | * ...
46 | * asio::ip::unicast::hops option;
47 | * socket.get_option(option);
48 | * int ttl = option.value();
49 | * @endcode
50 | *
51 | * @par Concepts:
52 | * GettableSocketOption, SettableSocketOption.
53 | */
54 | #if defined(GENERATING_DOCUMENTATION)
55 | typedef implementation_defined hops;
56 | #else
57 | typedef asio::ip::detail::socket_option::unicast_hops<
58 | ASIO_OS_DEF(IPPROTO_IP),
59 | ASIO_OS_DEF(IP_TTL),
60 | ASIO_OS_DEF(IPPROTO_IPV6),
61 | ASIO_OS_DEF(IPV6_UNICAST_HOPS)> hops;
62 | #endif
63 |
64 | } // namespace unicast
65 | } // namespace ip
66 | } // namespace asio
67 |
68 | #include "asio/detail/pop_options.hpp"
69 |
70 | #endif // ASIO_IP_UNICAST_HPP
71 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ip/v6_only.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ip/v6_only.hpp
3 | // ~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IP_V6_ONLY_HPP
12 | #define ASIO_IP_V6_ONLY_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/detail/socket_option.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace ip {
25 |
26 | /// Socket option for determining whether an IPv6 socket supports IPv6
27 | /// communication only.
28 | /**
29 | * Implements the IPPROTO_IPV6/IP_V6ONLY socket option.
30 | *
31 | * @par Examples
32 | * Setting the option:
33 | * @code
34 | * asio::ip::tcp::socket socket(io_service);
35 | * ...
36 | * asio::ip::v6_only option(true);
37 | * socket.set_option(option);
38 | * @endcode
39 | *
40 | * @par
41 | * Getting the current option value:
42 | * @code
43 | * asio::ip::tcp::socket socket(io_service);
44 | * ...
45 | * asio::ip::v6_only option;
46 | * socket.get_option(option);
47 | * bool v6_only = option.value();
48 | * @endcode
49 | *
50 | * @par Concepts:
51 | * GettableSocketOption, SettableSocketOption.
52 | */
53 | #if defined(GENERATING_DOCUMENTATION)
54 | typedef implementation_defined v6_only;
55 | #elif defined(IPV6_V6ONLY)
56 | typedef asio::detail::socket_option::boolean<
57 | IPPROTO_IPV6, IPV6_V6ONLY> v6_only;
58 | #else
59 | typedef asio::detail::socket_option::boolean<
60 | asio::detail::custom_socket_option_level,
61 | asio::detail::always_fail_option> v6_only;
62 | #endif
63 |
64 | } // namespace ip
65 | } // namespace asio
66 |
67 | #include "asio/detail/pop_options.hpp"
68 |
69 | #endif // ASIO_IP_V6_ONLY_HPP
70 |
--------------------------------------------------------------------------------
/src/include_asio/asio/is_read_buffered.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // is_read_buffered.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IS_READ_BUFFERED_HPP
12 | #define ASIO_IS_READ_BUFFERED_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/buffered_read_stream_fwd.hpp"
20 | #include "asio/buffered_stream_fwd.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 |
26 | namespace detail {
27 |
28 | template
29 | char is_read_buffered_helper(buffered_stream* s);
30 |
31 | template
32 | char is_read_buffered_helper(buffered_read_stream* s);
33 |
34 | struct is_read_buffered_big_type { char data[10]; };
35 | is_read_buffered_big_type is_read_buffered_helper(...);
36 |
37 | } // namespace detail
38 |
39 | /// The is_read_buffered class is a traits class that may be used to determine
40 | /// whether a stream type supports buffering of read data.
41 | template
42 | class is_read_buffered
43 | {
44 | public:
45 | #if defined(GENERATING_DOCUMENTATION)
46 | /// The value member is true only if the Stream type supports buffering of
47 | /// read data.
48 | static const bool value;
49 | #else
50 | ASIO_STATIC_CONSTANT(bool,
51 | value = sizeof(detail::is_read_buffered_helper((Stream*)0)) == 1);
52 | #endif
53 | };
54 |
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // ASIO_IS_READ_BUFFERED_HPP
60 |
--------------------------------------------------------------------------------
/src/include_asio/asio/is_write_buffered.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // is_write_buffered.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_IS_WRITE_BUFFERED_HPP
12 | #define ASIO_IS_WRITE_BUFFERED_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/buffered_stream_fwd.hpp"
20 | #include "asio/buffered_write_stream_fwd.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 |
26 | namespace detail {
27 |
28 | template
29 | char is_write_buffered_helper(buffered_stream* s);
30 |
31 | template
32 | char is_write_buffered_helper(buffered_write_stream* s);
33 |
34 | struct is_write_buffered_big_type { char data[10]; };
35 | is_write_buffered_big_type is_write_buffered_helper(...);
36 |
37 | } // namespace detail
38 |
39 | /// The is_write_buffered class is a traits class that may be used to determine
40 | /// whether a stream type supports buffering of written data.
41 | template
42 | class is_write_buffered
43 | {
44 | public:
45 | #if defined(GENERATING_DOCUMENTATION)
46 | /// The value member is true only if the Stream type supports buffering of
47 | /// written data.
48 | static const bool value;
49 | #else
50 | ASIO_STATIC_CONSTANT(bool,
51 | value = sizeof(detail::is_write_buffered_helper((Stream*)0)) == 1);
52 | #endif
53 | };
54 |
55 | } // namespace asio
56 |
57 | #include "asio/detail/pop_options.hpp"
58 |
59 | #endif // ASIO_IS_WRITE_BUFFERED_HPP
60 |
--------------------------------------------------------------------------------
/src/include_asio/asio/posix/stream_descriptor.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // posix/stream_descriptor.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_POSIX_STREAM_DESCRIPTOR_HPP
12 | #define ASIO_POSIX_STREAM_DESCRIPTOR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR) \
21 | || defined(GENERATING_DOCUMENTATION)
22 |
23 | #include "asio/posix/basic_stream_descriptor.hpp"
24 |
25 | namespace asio {
26 | namespace posix {
27 |
28 | /// Typedef for the typical usage of a stream-oriented descriptor.
29 | typedef basic_stream_descriptor<> stream_descriptor;
30 |
31 | } // namespace posix
32 | } // namespace asio
33 |
34 | #endif // defined(ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
35 | // || defined(GENERATING_DOCUMENTATION)
36 |
37 | #endif // ASIO_POSIX_STREAM_DESCRIPTOR_HPP
38 |
--------------------------------------------------------------------------------
/src/include_asio/asio/serial_port.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // serial_port.hpp
3 | // ~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | // Copyright (c) 2008 Rep Invariant Systems, Inc. (info@repinvariant.com)
7 | //
8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 | //
11 |
12 | #ifndef ASIO_SERIAL_PORT_HPP
13 | #define ASIO_SERIAL_PORT_HPP
14 |
15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 | # pragma once
17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 |
19 | #include "asio/detail/config.hpp"
20 |
21 | #if defined(ASIO_HAS_SERIAL_PORT) \
22 | || defined(GENERATING_DOCUMENTATION)
23 |
24 | #include "asio/basic_serial_port.hpp"
25 |
26 | namespace asio {
27 |
28 | /// Typedef for the typical usage of a serial port.
29 | typedef basic_serial_port<> serial_port;
30 |
31 | } // namespace asio
32 |
33 | #endif // defined(ASIO_HAS_SERIAL_PORT)
34 | // || defined(GENERATING_DOCUMENTATION)
35 |
36 | #endif // ASIO_SERIAL_PORT_HPP
37 |
--------------------------------------------------------------------------------
/src/include_asio/asio/signal_set.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // signal_set.hpp
3 | // ~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SIGNAL_SET_HPP
12 | #define ASIO_SIGNAL_SET_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/basic_signal_set.hpp"
20 |
21 | namespace asio {
22 |
23 | /// Typedef for the typical usage of a signal set.
24 | typedef basic_signal_set<> signal_set;
25 |
26 | } // namespace asio
27 |
28 | #endif // ASIO_SIGNAL_SET_HPP
29 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl.hpp
3 | // ~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_HPP
12 | #define ASIO_SSL_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/ssl/basic_context.hpp"
19 | #include "asio/ssl/context.hpp"
20 | #include "asio/ssl/context_base.hpp"
21 | #include "asio/ssl/context_service.hpp"
22 | #include "asio/ssl/error.hpp"
23 | #include "asio/ssl/rfc2818_verification.hpp"
24 | #include "asio/ssl/stream.hpp"
25 | #include "asio/ssl/stream_base.hpp"
26 | #include "asio/ssl/stream_service.hpp"
27 | #include "asio/ssl/verify_context.hpp"
28 | #include "asio/ssl/verify_mode.hpp"
29 |
30 | #endif // ASIO_SSL_HPP
31 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/basic_context.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/basic_context.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_BASIC_CONTEXT_HPP
12 | #define ASIO_SSL_BASIC_CONTEXT_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/old/basic_context.hpp"
22 | #endif // defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 |
29 | #if defined(ASIO_ENABLE_OLD_SSL)
30 |
31 | using asio::ssl::old::basic_context;
32 |
33 | #endif // defined(ASIO_ENABLE_OLD_SSL)
34 |
35 | } // namespace ssl
36 | } // namespace asio
37 |
38 | #include "asio/detail/pop_options.hpp"
39 |
40 | #endif // ASIO_SSL_BASIC_CONTEXT_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/context_service.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/context_service.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_CONTEXT_SERVICE_HPP
12 | #define ASIO_SSL_CONTEXT_SERVICE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/old/context_service.hpp"
22 | #endif // defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 |
29 | #if defined(ASIO_ENABLE_OLD_SSL)
30 |
31 | using asio::ssl::old::context_service;
32 |
33 | #endif // defined(ASIO_ENABLE_OLD_SSL)
34 |
35 | } // namespace ssl
36 | } // namespace asio
37 |
38 | #include "asio/detail/pop_options.hpp"
39 |
40 | #endif // ASIO_SSL_CONTEXT_SERVICE_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/handshake_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/handshake_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_HANDSHAKE_OP_HPP
12 | #define ASIO_SSL_DETAIL_HANDSHAKE_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/detail/engine.hpp"
22 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 | namespace detail {
29 |
30 | #if !defined(ASIO_ENABLE_OLD_SSL)
31 |
32 | class handshake_op
33 | {
34 | public:
35 | handshake_op(stream_base::handshake_type type)
36 | : type_(type)
37 | {
38 | }
39 |
40 | engine::want operator()(engine& eng,
41 | asio::error_code& ec,
42 | std::size_t& bytes_transferred) const
43 | {
44 | bytes_transferred = 0;
45 | return eng.handshake(type_, ec);
46 | }
47 |
48 | template
49 | void call_handler(Handler& handler,
50 | const asio::error_code& ec,
51 | const std::size_t&) const
52 | {
53 | handler(ec);
54 | }
55 |
56 | private:
57 | stream_base::handshake_type type_;
58 | };
59 |
60 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
61 |
62 | } // namespace detail
63 | } // namespace ssl
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #endif // ASIO_SSL_DETAIL_HANDSHAKE_OP_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/openssl_types.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/openssl_types.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP
12 | #define ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include
20 | #include
21 | #if !defined(OPENSSL_NO_ENGINE)
22 | # include
23 | #endif // !defined(OPENSSL_NO_ENGINE)
24 | #include
25 | #include
26 | #include "asio/detail/socket_types.hpp"
27 |
28 | #endif // ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP
29 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/password_callback.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/password_callback.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_PASSWORD_CALLBACK_HPP
12 | #define ASIO_SSL_DETAIL_PASSWORD_CALLBACK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include
22 | # include
23 | # include "asio/ssl/context_base.hpp"
24 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
25 |
26 | #include "asio/detail/push_options.hpp"
27 |
28 | namespace asio {
29 | namespace ssl {
30 | namespace detail {
31 |
32 | #if !defined(ASIO_ENABLE_OLD_SSL)
33 |
34 | class password_callback_base
35 | {
36 | public:
37 | virtual ~password_callback_base()
38 | {
39 | }
40 |
41 | virtual std::string call(std::size_t size,
42 | context_base::password_purpose purpose) = 0;
43 | };
44 |
45 | template
46 | class password_callback : public password_callback_base
47 | {
48 | public:
49 | explicit password_callback(PasswordCallback callback)
50 | : callback_(callback)
51 | {
52 | }
53 |
54 | virtual std::string call(std::size_t size,
55 | context_base::password_purpose purpose)
56 | {
57 | return callback_(size, purpose);
58 | }
59 |
60 | private:
61 | PasswordCallback callback_;
62 | };
63 |
64 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
65 |
66 | } // namespace detail
67 | } // namespace ssl
68 | } // namespace asio
69 |
70 | #include "asio/detail/pop_options.hpp"
71 |
72 | #endif // ASIO_SSL_DETAIL_PASSWORD_CALLBACK_HPP
73 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/read_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/read_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_READ_OP_HPP
12 | #define ASIO_SSL_DETAIL_READ_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/detail/buffer_sequence_adapter.hpp"
22 | # include "asio/ssl/detail/engine.hpp"
23 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace ssl {
29 | namespace detail {
30 |
31 | #if !defined(ASIO_ENABLE_OLD_SSL)
32 |
33 | template
34 | class read_op
35 | {
36 | public:
37 | read_op(const MutableBufferSequence& buffers)
38 | : buffers_(buffers)
39 | {
40 | }
41 |
42 | engine::want operator()(engine& eng,
43 | asio::error_code& ec,
44 | std::size_t& bytes_transferred) const
45 | {
46 | asio::mutable_buffer buffer =
47 | asio::detail::buffer_sequence_adapter::first(buffers_);
49 |
50 | return eng.read(buffer, ec, bytes_transferred);
51 | }
52 |
53 | template
54 | void call_handler(Handler& handler,
55 | const asio::error_code& ec,
56 | const std::size_t& bytes_transferred) const
57 | {
58 | handler(ec, bytes_transferred);
59 | }
60 |
61 | private:
62 | MutableBufferSequence buffers_;
63 | };
64 |
65 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
66 |
67 | } // namespace detail
68 | } // namespace ssl
69 | } // namespace asio
70 |
71 | #include "asio/detail/pop_options.hpp"
72 |
73 | #endif // ASIO_SSL_DETAIL_READ_OP_HPP
74 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/shutdown_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/shutdown_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_SHUTDOWN_OP_HPP
12 | #define ASIO_SSL_DETAIL_SHUTDOWN_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/detail/engine.hpp"
22 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 | namespace detail {
29 |
30 | #if !defined(ASIO_ENABLE_OLD_SSL)
31 |
32 | class shutdown_op
33 | {
34 | public:
35 | engine::want operator()(engine& eng,
36 | asio::error_code& ec,
37 | std::size_t& bytes_transferred) const
38 | {
39 | bytes_transferred = 0;
40 | return eng.shutdown(ec);
41 | }
42 |
43 | template
44 | void call_handler(Handler& handler,
45 | const asio::error_code& ec,
46 | const std::size_t&) const
47 | {
48 | handler(ec);
49 | }
50 | };
51 |
52 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
53 |
54 | } // namespace detail
55 | } // namespace ssl
56 | } // namespace asio
57 |
58 | #include "asio/detail/pop_options.hpp"
59 |
60 | #endif // ASIO_SSL_DETAIL_SHUTDOWN_OP_HPP
61 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/verify_callback.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/verify_callback.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP
12 | #define ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/verify_context.hpp"
22 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 | namespace detail {
29 |
30 | #if !defined(ASIO_ENABLE_OLD_SSL)
31 |
32 | class verify_callback_base
33 | {
34 | public:
35 | virtual ~verify_callback_base()
36 | {
37 | }
38 |
39 | virtual bool call(bool preverified, verify_context& ctx) = 0;
40 | };
41 |
42 | template
43 | class verify_callback : public verify_callback_base
44 | {
45 | public:
46 | explicit verify_callback(VerifyCallback callback)
47 | : callback_(callback)
48 | {
49 | }
50 |
51 | virtual bool call(bool preverified, verify_context& ctx)
52 | {
53 | return callback_(preverified, ctx);
54 | }
55 |
56 | private:
57 | VerifyCallback callback_;
58 | };
59 |
60 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
61 |
62 | } // namespace detail
63 | } // namespace ssl
64 | } // namespace asio
65 |
66 | #include "asio/detail/pop_options.hpp"
67 |
68 | #endif // ASIO_SSL_DETAIL_VERIFY_CALLBACK_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/detail/write_op.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/detail/write_op.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_DETAIL_WRITE_OP_HPP
12 | #define ASIO_SSL_DETAIL_WRITE_OP_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/detail/buffer_sequence_adapter.hpp"
22 | # include "asio/ssl/detail/engine.hpp"
23 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
24 |
25 | #include "asio/detail/push_options.hpp"
26 |
27 | namespace asio {
28 | namespace ssl {
29 | namespace detail {
30 |
31 | #if !defined(ASIO_ENABLE_OLD_SSL)
32 |
33 | template
34 | class write_op
35 | {
36 | public:
37 | write_op(const ConstBufferSequence& buffers)
38 | : buffers_(buffers)
39 | {
40 | }
41 |
42 | engine::want operator()(engine& eng,
43 | asio::error_code& ec,
44 | std::size_t& bytes_transferred) const
45 | {
46 | asio::const_buffer buffer =
47 | asio::detail::buffer_sequence_adapter::first(buffers_);
49 |
50 | return eng.write(buffer, ec, bytes_transferred);
51 | }
52 |
53 | template
54 | void call_handler(Handler& handler,
55 | const asio::error_code& ec,
56 | const std::size_t& bytes_transferred) const
57 | {
58 | handler(ec, bytes_transferred);
59 | }
60 |
61 | private:
62 | ConstBufferSequence buffers_;
63 | };
64 |
65 | #endif // !defined(ASIO_ENABLE_OLD_SSL)
66 |
67 | } // namespace detail
68 | } // namespace ssl
69 | } // namespace asio
70 |
71 | #include "asio/detail/pop_options.hpp"
72 |
73 | #endif // ASIO_SSL_DETAIL_WRITE_OP_HPP
74 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/error.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/error.hpp
3 | // ~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_ERROR_HPP
12 | #define ASIO_SSL_ERROR_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/error_code.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace error {
25 |
26 | enum ssl_errors
27 | {
28 | };
29 |
30 | extern ASIO_DECL
31 | const asio::error_category& get_ssl_category();
32 |
33 | static const asio::error_category& ssl_category
34 | = asio::error::get_ssl_category();
35 |
36 | } // namespace error
37 | } // namespace asio
38 |
39 | #if defined(ASIO_HAS_STD_SYSTEM_ERROR)
40 | namespace std {
41 |
42 | template<> struct is_error_code_enum
43 | {
44 | static const bool value = true;
45 | };
46 |
47 | } // namespace std
48 | #endif // defined(ASIO_HAS_STD_SYSTEM_ERROR)
49 |
50 | namespace asio {
51 | namespace error {
52 |
53 | inline asio::error_code make_error_code(ssl_errors e)
54 | {
55 | return asio::error_code(
56 | static_cast(e), get_ssl_category());
57 | }
58 |
59 | } // namespace error
60 | } // namespace asio
61 |
62 | #include "asio/detail/pop_options.hpp"
63 |
64 | #if defined(ASIO_HEADER_ONLY)
65 | # include "asio/ssl/impl/error.ipp"
66 | #endif // defined(ASIO_HEADER_ONLY)
67 |
68 | #endif // ASIO_SSL_ERROR_HPP
69 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/impl/error.ipp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/impl/error.ipp
3 | // ~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_IMPL_ERROR_IPP
12 | #define ASIO_SSL_IMPL_ERROR_IPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/ssl/error.hpp"
20 | #include "asio/ssl/detail/openssl_init.hpp"
21 |
22 | #include "asio/detail/push_options.hpp"
23 |
24 | namespace asio {
25 | namespace error {
26 |
27 | namespace detail {
28 |
29 | class ssl_category : public asio::error_category
30 | {
31 | public:
32 | const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT
33 | {
34 | return "asio.ssl";
35 | }
36 |
37 | std::string message(int value) const
38 | {
39 | const char* s = ::ERR_reason_error_string(value);
40 | return s ? s : "asio.ssl error";
41 | }
42 | };
43 |
44 | } // namespace detail
45 |
46 | const asio::error_category& get_ssl_category()
47 | {
48 | static detail::ssl_category instance;
49 | return instance;
50 | }
51 |
52 | } // namespace error
53 | } // namespace asio
54 |
55 | #include "asio/detail/pop_options.hpp"
56 |
57 | #endif // ASIO_SSL_IMPL_ERROR_IPP
58 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/impl/src.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // impl/ssl/src.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_IMPL_SRC_HPP
12 | #define ASIO_SSL_IMPL_SRC_HPP
13 |
14 | #define ASIO_SOURCE
15 |
16 | #include "asio/detail/config.hpp"
17 |
18 | #if defined(ASIO_HEADER_ONLY)
19 | # error Do not compile Asio library source with ASIO_HEADER_ONLY defined
20 | #endif
21 |
22 | #include "asio/ssl/impl/context.ipp"
23 | #include "asio/ssl/impl/error.ipp"
24 | #include "asio/ssl/detail/impl/engine.ipp"
25 | #include "asio/ssl/detail/impl/openssl_init.ipp"
26 | #include "asio/ssl/impl/rfc2818_verification.ipp"
27 |
28 | #endif // ASIO_SSL_IMPL_SRC_HPP
29 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/stream_base.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/stream_base.hpp
3 | // ~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_STREAM_BASE_HPP
12 | #define ASIO_SSL_STREAM_BASE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #include "asio/detail/push_options.hpp"
21 |
22 | namespace asio {
23 | namespace ssl {
24 |
25 | /// The stream_base class is used as a base for the asio::ssl::stream
26 | /// class template so that we have a common place to define various enums.
27 | class stream_base
28 | {
29 | public:
30 | /// Different handshake types.
31 | enum handshake_type
32 | {
33 | /// Perform handshaking as a client.
34 | client,
35 |
36 | /// Perform handshaking as a server.
37 | server
38 | };
39 |
40 | protected:
41 | /// Protected destructor to prevent deletion through this type.
42 | ~stream_base()
43 | {
44 | }
45 | };
46 |
47 | } // namespace ssl
48 | } // namespace asio
49 |
50 | #include "asio/detail/pop_options.hpp"
51 |
52 | #endif // ASIO_SSL_STREAM_BASE_HPP
53 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/stream_service.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/stream_service.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_STREAM_SERVICE_HPP
12 | #define ASIO_SSL_STREAM_SERVICE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_ENABLE_OLD_SSL)
21 | # include "asio/ssl/old/stream_service.hpp"
22 | #endif // defined(ASIO_ENABLE_OLD_SSL)
23 |
24 | #include "asio/detail/push_options.hpp"
25 |
26 | namespace asio {
27 | namespace ssl {
28 |
29 | #if defined(ASIO_ENABLE_OLD_SSL)
30 |
31 | using asio::ssl::old::stream_service;
32 |
33 | #endif // defined(ASIO_ENABLE_OLD_SSL)
34 |
35 | } // namespace ssl
36 | } // namespace asio
37 |
38 | #include "asio/detail/pop_options.hpp"
39 |
40 | #endif // ASIO_SSL_STREAM_SERVICE_HPP
41 |
--------------------------------------------------------------------------------
/src/include_asio/asio/ssl/verify_mode.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // ssl/verify_mode.hpp
3 | // ~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SSL_VERIFY_MODE_HPP
12 | #define ASIO_SSL_VERIFY_MODE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 | #include "asio/ssl/detail/openssl_types.hpp"
20 |
21 | #include "asio/detail/push_options.hpp"
22 |
23 | namespace asio {
24 | namespace ssl {
25 |
26 | /// Bitmask type for peer verification.
27 | /**
28 | * Possible values are:
29 | *
30 | * @li @ref verify_none
31 | * @li @ref verify_peer
32 | * @li @ref verify_fail_if_no_peer_cert
33 | * @li @ref verify_client_once
34 | */
35 | typedef int verify_mode;
36 |
37 | #if defined(GENERATING_DOCUMENTATION)
38 | /// No verification.
39 | const int verify_none = implementation_defined;
40 |
41 | /// Verify the peer.
42 | const int verify_peer = implementation_defined;
43 |
44 | /// Fail verification if the peer has no certificate. Ignored unless
45 | /// @ref verify_peer is set.
46 | const int verify_fail_if_no_peer_cert = implementation_defined;
47 |
48 | /// Do not request client certificate on renegotiation. Ignored unless
49 | /// @ref verify_peer is set.
50 | const int verify_client_once = implementation_defined;
51 | #else
52 | const int verify_none = SSL_VERIFY_NONE;
53 | const int verify_peer = SSL_VERIFY_PEER;
54 | const int verify_fail_if_no_peer_cert = SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
55 | const int verify_client_once = SSL_VERIFY_CLIENT_ONCE;
56 | #endif
57 |
58 | } // namespace ssl
59 | } // namespace asio
60 |
61 | #include "asio/detail/pop_options.hpp"
62 |
63 | #endif // ASIO_SSL_VERIFY_MODE_HPP
64 |
--------------------------------------------------------------------------------
/src/include_asio/asio/streambuf.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // streambuf.hpp
3 | // ~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_STREAMBUF_HPP
12 | #define ASIO_STREAMBUF_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if !defined(ASIO_NO_IOSTREAM)
21 |
22 | #include "asio/basic_streambuf.hpp"
23 |
24 | namespace asio {
25 |
26 | /// Typedef for the typical usage of basic_streambuf.
27 | typedef basic_streambuf<> streambuf;
28 |
29 | } // namespace asio
30 |
31 | #endif // !defined(ASIO_NO_IOSTREAM)
32 |
33 | #endif // ASIO_STREAMBUF_HPP
34 |
--------------------------------------------------------------------------------
/src/include_asio/asio/system_timer.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // system_timer.hpp
3 | // ~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_SYSTEM_TIMER_HPP
12 | #define ASIO_SYSTEM_TIMER_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_STD_CHRONO) \
21 | || defined(ASIO_HAS_BOOST_CHRONO) \
22 | || defined(GENERATING_DOCUMENTATION)
23 |
24 | #if defined(ASIO_HAS_STD_CHRONO)
25 | # include
26 | #elif defined(ASIO_HAS_BOOST_CHRONO)
27 | # include
28 | #endif
29 |
30 | #include "asio/basic_waitable_timer.hpp"
31 |
32 | namespace asio {
33 |
34 | #if defined(GENERATING_DOCUMENTATION)
35 | /// Typedef for a timer based on the system clock.
36 | /**
37 | * This typedef uses the C++11 @c <chrono> standard library facility, if
38 | * available. Otherwise, it may use the Boost.Chrono library. To explicitly
39 | * utilise Boost.Chrono, use the basic_waitable_timer template directly:
40 | * @code
41 | * typedef basic_waitable_timer timer;
42 | * @endcode
43 | */
44 | typedef basic_waitable_timer system_timer;
45 | #elif defined(ASIO_HAS_STD_CHRONO)
46 | typedef basic_waitable_timer system_timer;
47 | #elif defined(ASIO_HAS_BOOST_CHRONO)
48 | typedef basic_waitable_timer system_timer;
49 | #endif
50 |
51 | } // namespace asio
52 |
53 | #endif // defined(ASIO_HAS_STD_CHRONO)
54 | // || defined(ASIO_HAS_BOOST_CHRONO)
55 | // || defined(GENERATING_DOCUMENTATION)
56 |
57 | #endif // ASIO_SYSTEM_TIMER_HPP
58 |
--------------------------------------------------------------------------------
/src/include_asio/asio/unyield.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // unyield.hpp
3 | // ~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifdef reenter
12 | # undef reenter
13 | #endif
14 |
15 | #ifdef yield
16 | # undef yield
17 | #endif
18 |
19 | #ifdef fork
20 | # undef fork
21 | #endif
22 |
--------------------------------------------------------------------------------
/src/include_asio/asio/version.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // version.hpp
3 | // ~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_VERSION_HPP
12 | #define ASIO_VERSION_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | // ASIO_VERSION % 100 is the sub-minor version
19 | // ASIO_VERSION / 100 % 1000 is the minor version
20 | // ASIO_VERSION / 100000 is the major version
21 | #define ASIO_VERSION 101002 // 1.10.2
22 |
23 | #endif // ASIO_VERSION_HPP
24 |
--------------------------------------------------------------------------------
/src/include_asio/asio/wait_traits.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // wait_traits.hpp
3 | // ~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_WAIT_TRAITS_HPP
12 | #define ASIO_WAIT_TRAITS_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/push_options.hpp"
19 |
20 | namespace asio {
21 |
22 | /// Wait traits suitable for use with the basic_waitable_timer class template.
23 | template
24 | struct wait_traits
25 | {
26 | /// Convert a clock duration into a duration used for waiting.
27 | /**
28 | * @returns @c d.
29 | */
30 | static typename Clock::duration to_wait_duration(
31 | const typename Clock::duration& d)
32 | {
33 | return d;
34 | }
35 | };
36 |
37 | } // namespace asio
38 |
39 | #include "asio/detail/pop_options.hpp"
40 |
41 | #endif // ASIO_WAIT_TRAITS_HPP
42 |
--------------------------------------------------------------------------------
/src/include_asio/asio/windows/object_handle.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // windows/object_handle.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | // Copyright (c) 2011 Boris Schaeling (boris@highscore.de)
7 | //
8 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 | //
11 |
12 | #ifndef ASIO_WINDOWS_OBJECT_HANDLE_HPP
13 | #define ASIO_WINDOWS_OBJECT_HANDLE_HPP
14 |
15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 | # pragma once
17 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 |
19 | #include "asio/detail/config.hpp"
20 |
21 | #if defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
22 | || defined(GENERATING_DOCUMENTATION)
23 |
24 | #include "asio/windows/basic_object_handle.hpp"
25 |
26 | namespace asio {
27 | namespace windows {
28 |
29 | /// Typedef for the typical usage of an object handle.
30 | typedef basic_object_handle<> object_handle;
31 |
32 | } // namespace windows
33 | } // namespace asio
34 |
35 | #endif // defined(ASIO_HAS_WINDOWS_OBJECT_HANDLE)
36 | // || defined(GENERATING_DOCUMENTATION)
37 |
38 | #endif // ASIO_WINDOWS_OBJECT_HANDLE_HPP
39 |
--------------------------------------------------------------------------------
/src/include_asio/asio/windows/random_access_handle.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // windows/random_access_handle.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP
12 | #define ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE) \
21 | || defined(GENERATING_DOCUMENTATION)
22 |
23 | #include "asio/windows/basic_random_access_handle.hpp"
24 |
25 | namespace asio {
26 | namespace windows {
27 |
28 | /// Typedef for the typical usage of a random-access handle.
29 | typedef basic_random_access_handle<> random_access_handle;
30 |
31 | } // namespace windows
32 | } // namespace asio
33 |
34 | #endif // defined(ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE)
35 | // || defined(GENERATING_DOCUMENTATION)
36 |
37 | #endif // ASIO_WINDOWS_RANDOM_ACCESS_HANDLE_HPP
38 |
--------------------------------------------------------------------------------
/src/include_asio/asio/windows/stream_handle.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // windows/stream_handle.hpp
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #ifndef ASIO_WINDOWS_STREAM_HANDLE_HPP
12 | #define ASIO_WINDOWS_STREAM_HANDLE_HPP
13 |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 | # pragma once
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 |
18 | #include "asio/detail/config.hpp"
19 |
20 | #if defined(ASIO_HAS_WINDOWS_STREAM_HANDLE) \
21 | || defined(GENERATING_DOCUMENTATION)
22 |
23 | #include "asio/windows/basic_stream_handle.hpp"
24 |
25 | namespace asio {
26 | namespace windows {
27 |
28 | /// Typedef for the typical usage of a stream-oriented handle.
29 | typedef basic_stream_handle<> stream_handle;
30 |
31 | } // namespace windows
32 | } // namespace asio
33 |
34 | #endif // defined(ASIO_HAS_WINDOWS_STREAM_HANDLE)
35 | // || defined(GENERATING_DOCUMENTATION)
36 |
37 | #endif // ASIO_WINDOWS_STREAM_HANDLE_HPP
38 |
--------------------------------------------------------------------------------
/src/include_asio/asio/yield.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // yield.hpp
3 | // ~~~~~~~~~
4 | //
5 | // Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 | //
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 | //
10 |
11 | #include "coroutine.hpp"
12 |
13 | #ifndef reenter
14 | # define reenter(c) ASIO_CORO_REENTER(c)
15 | #endif
16 |
17 | #ifndef yield
18 | # define yield ASIO_CORO_YIELD
19 | #endif
20 |
21 | #ifndef fork
22 | # define fork ASIO_CORO_FORK
23 | #endif
24 |
--------------------------------------------------------------------------------
/src/ioserviceclass.h:
--------------------------------------------------------------------------------
1 | #ifndef IOSERVICECLASS_H
2 | #define IOSERVICECLASS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "include_asio/asio.hpp"
9 |
10 | typedef asio::io_service IO_Service;
11 | typedef asio::io_service::work IO_Service_work;
12 |
13 | class IOServiceClass
14 | {
15 | public:
16 | explicit IOServiceClass(int size = 1) {
17 | work = new IO_Service_work(service);
18 | if (size < 1) size = 1;
19 | addThread(size);
20 | }
21 |
22 | ~IOServiceClass() {
23 | delete work;
24 | service.stop();
25 | for (std::thread * th : threadlist) {
26 | // th->join();
27 | delete th;
28 | }
29 | }
30 | int setThreadSize(int size = 0) {
31 | int csize = getThreadSize();
32 | if (size <= csize) {
33 | return csize;
34 | } else {
35 | addThread(csize - size);
36 | return size;
37 | }
38 | }
39 | int getThreadSize() const {return threadlist.size();}
40 | IO_Service & getService() { return service;}
41 |
42 | protected:
43 | void addThread(int size){
44 | for (int i = 0; i < size; ++i) {
45 | std::thread * th = new std::thread(
46 | std::bind(static_cast(&IO_Service::run), &service));
47 | threadlist.push_back(th);
48 | th->detach();
49 | }
50 | }
51 | private:
52 | IOServiceClass(const IOServiceClass &) = delete;
53 | IOServiceClass & operator=(const IOServiceClass & ) = delete;
54 | IO_Service service;
55 | IO_Service_work * work;
56 | std::vector threadlist;
57 | };
58 |
59 | #endif // IOSERVICECLASS_H
60 |
--------------------------------------------------------------------------------
/src/qasiosocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOSOCKET_H
2 | #define QASIOSOCKET_H
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #if defined(QASIOSOCKET_NOLIB)
10 |
11 | #define QASIOSOCKET_EXPORT
12 |
13 | #elif defined(QASIOSOCKET_LIBRARY)
14 |
15 | #define QASIOSOCKET_EXPORT Q_DECL_EXPORT
16 |
17 | #else
18 |
19 | #define QASIOSOCKET_EXPORT Q_DECL_IMPORT
20 |
21 | #endif
22 |
23 |
24 | //#define QASIOSOCKET_EXPORT Q_CORE_EXPORT
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/src/qasiosslsocket.cpp:
--------------------------------------------------------------------------------
1 | #ifdef QASIO_SSL
2 | #include "qasiosslsocket.h"
3 | #include "qsocketconnection.h"
4 |
5 | QAsioSslSocket::QAsioSslSocket(SSLSession *session):
6 | TcpAbstractSocket(0),con_(session)
7 | {
8 | int soc = con_->connection->socketDescriptor();
9 | if (soc != -1) {
10 | setState(ConnectedState);
11 | setSocketPtr(soc);
12 | }
13 | con_->connection->setQTcp(this);
14 | }
15 |
16 | QAsioSslSocket::~QAsioSslSocket()
17 | {
18 | con_->connection->setQTcp(nullptr);
19 | delete con_;
20 | }
21 |
22 | void QAsioSslSocket::do_start()
23 | {
24 | con_->connection->do_read();
25 | }
26 |
27 |
28 | void QAsioSslSocket::disconnectFromHost()
29 | {
30 | if (state() == UnconnectedState) return;
31 | con_->connection->disconnectFromHost();
32 | }
33 |
34 | void QAsioSslSocket::sendData(const char * data, int size)
35 | {
36 | if (state() == ConnectedState)
37 | con_->connection->wirteData(data,size);
38 | }
39 |
40 | void QAsioSslSocket::setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value)
41 | {
42 | con_->connection->setSocketOption(option,isEnble,value);
43 | }
44 |
45 | std::pair QAsioSslSocket::getSocketOption(TcpAbstractSocket::SocketOption opention)
46 | {
47 | return con_->connection->getSocketOption(opention);
48 | }
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/qasiosslsocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOSSLSOCKET_H
2 | #define QASIOSSLSOCKET_H
3 |
4 | #include "tcpabstractsocket.h"
5 | #ifdef QASIO_SSL
6 |
7 | class SSLSession;
8 |
9 | class QASIOSOCKET_EXPORT QAsioSslSocket : public TcpAbstractSocket
10 | {
11 | Q_OBJECT
12 | public:
13 | QAsioSslSocket(SSLSession * session);
14 | virtual ~QAsioSslSocket();
15 | public slots:
16 | void disconnectFromHost();
17 |
18 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
19 |
20 | std::pair getSocketOption(TcpAbstractSocket::SocketOption);
21 |
22 | void do_start();
23 | protected slots:
24 | void sendData(const char * data, int size);
25 | void connectToHost(const QString &/*hostName*/, quint16 /*port*/)
26 | {}
27 | private:
28 | SSLSession * con_;
29 | Q_DISABLE_COPY(QAsioSslSocket)
30 | };
31 |
32 | #endif //asio_ssl
33 |
34 | #endif // QASIOSSLSOCKET_H
35 |
--------------------------------------------------------------------------------
/src/qasiotcpserver.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOTCPSERVER_H
2 | #define QASIOTCPSERVER_H
3 |
4 | #include
5 | #include "qasiotcpsocket.h"
6 |
7 | struct SocketSession;
8 | struct Session;
9 |
10 | class QASIOSOCKET_EXPORT QAsioTcpServer : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit QAsioTcpServer(size_t socket_buffer = 4096,QObject *parent = 0);
15 | ~QAsioTcpServer();
16 |
17 | signals:
18 | void newConnection(QAsioTcpsocket * socket);
19 |
20 | void deleteAllLink();
21 | public :
22 | bool listen(const QString & ip,qint16 port);
23 | bool listen(qint16 port,bool isV6 = false);
24 |
25 | void close();
26 |
27 | void setSocketOption(TcpAbstractSocket::SocketOption option, uint value) {
28 | setSocketOption(option,false,value);
29 | }
30 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble) {
31 | setSocketOption(option,isEnble,0);
32 | }
33 |
34 | void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
35 |
36 | int setThreadSize(int size);
37 | protected:
38 | virtual void incomingConnection(Session * session);
39 | private:
40 | SocketSession * listen_session;
41 | friend struct SocketSession;
42 | };
43 |
44 | #endif // QASIOTCPSERVER_H
45 |
--------------------------------------------------------------------------------
/src/qasiotcpsocket.h:
--------------------------------------------------------------------------------
1 | #ifndef QASIOTCPSOCKET_H
2 | #define QASIOTCPSOCKET_H
3 | #include "tcpabstractsocket.h"
4 |
5 | struct Session;
6 | class IOServiceClass;
7 |
8 | class QASIOSOCKET_EXPORT QAsioTcpsocket : public TcpAbstractSocket
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit QAsioTcpsocket(size_t size = 4096,QObject *parent = 0);
13 | QAsioTcpsocket(Session *ses);
14 | ~QAsioTcpsocket();
15 |
16 | signals:
17 |
18 | public slots:
19 | void connectToHost(const QString &hostName, quint16 port);
20 |
21 | void disconnectFromHost();
22 |
23 | virtual void setSocketOption(TcpAbstractSocket::SocketOption option, bool isEnble, uint value);
24 |
25 | virtual std::pair getSocketOption(TcpAbstractSocket::SocketOption opention);
26 |
27 | void do_start();
28 |
29 | int resizeClientBackThreadSize(int size);
30 | protected:
31 | virtual void hostConnected();
32 | void sendData(const char * data, int size);
33 | private:
34 | bool serverBuild;
35 | Session * con_;
36 | static IOServiceClass * ioserver;
37 | static volatile ulong linkCout;
38 | Q_DISABLE_COPY(QAsioTcpsocket)
39 | };
40 |
41 | #endif // QASIOTCPSOCKET_H
42 |
--------------------------------------------------------------------------------
/src/src.pro:
--------------------------------------------------------------------------------
1 | QT += core
2 |
3 | TEMPLATE = lib
4 | DEFINES += QASIOSOCKET_LIBRARY QASIO_SSL
5 | DESTDIR = $$PWD/../lib
6 | DEFINES += _WIN32_WINNT=0x0501
7 |
8 | TARGET = $$qtLibraryTarget(QAsioSocket)
9 |
10 | include($$PWD/../QAsioSocket.pri)
11 |
12 | win32{
13 | INCLUDEPATH += $$(OPENSSL)/include/
14 | msvc {
15 | CONFIG(release, debug|release): LIBS += -L$$(OPENSSL)/lib/VC/ -lssleay32M
16 | else:CONFIG(debug, debug|release): LIBS += -L$$(OPENSSL)/lib/VC/ -lssleay32Md
17 |
18 | CONFIG(release, debug|release): LIBS += -L$$(OPENSSL)/lib/VC/ -llibeay32M
19 | else:CONFIG(debug, debug|release): LIBS += -L$$(OPENSSL)/lib/VC/ -llibeay32Md
20 | } else {
21 | LIBS += -L$$(OPENSSL)/lib/MinGW/ -leay32
22 | LIBS += -L$$(OPENSSL)/lib/MinGW/ -lssleay32
23 | }
24 | }
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/client/client.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2013-09-18T08:44:16
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = TcpClient
12 | TEMPLATE = app
13 |
14 | CONFIG += C++11
15 |
16 | SOURCES += main.cpp\
17 | mainwindow.cpp
18 |
19 | HEADERS += mainwindow.h
20 |
21 | FORMS += mainwindow.ui
22 |
23 | #include($$PWD/../../QAsioSocket.pri)
24 |
25 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocket
26 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocketd
27 | else:unix: LIBS += -L$$PWD/../../lib/ -lQAsioSocket
28 |
29 | INCLUDEPATH += $$PWD/../../include
30 | DEPENDPATH += $$PWD/../../include
31 |
--------------------------------------------------------------------------------
/test/client/main.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | MainWindow w;
8 | w.show();
9 |
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/test/client/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace Ui {
9 | class MainWindow;
10 | }
11 |
12 | class MainWindow : public QMainWindow
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | explicit MainWindow(QWidget *parent = 0);
18 | ~MainWindow();
19 |
20 | public slots:
21 | void readError(const QString & erro);
22 |
23 | void on_pushSent_clicked();
24 | void on_pushConnect_clicked();
25 | void on_timeBut_clicked();
26 |
27 | void connectdd();
28 | void disconnectdd();
29 | void readData(const QByteArray & data);
30 | private:
31 | Ui::MainWindow * ui;
32 | QAsioTcpsocket * socket;
33 | QTimer tm;
34 | QStringList list;
35 | };
36 |
37 | #endif // MAINWINDOW_H
38 |
--------------------------------------------------------------------------------
/test/msslserver/main.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | MainWindow w;
8 | w.show();
9 |
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/test/msslserver/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include "ui_mainwindow.h"
3 |
4 | MainWindow::MainWindow(QWidget *parent) :
5 | QMainWindow(parent),
6 | ui(new Ui::MainWindow)
7 | {
8 | ui->setupUi(this);
9 | this->ui->pushButton_2->setEnabled(false);
10 | }
11 |
12 | MainWindow::~MainWindow()
13 | {
14 | delete ui;
15 | }
16 |
17 | void MainWindow::on_pushButton_clicked()
18 | {
19 | this->ui->pushButton_2->setEnabled(true);
20 | this->ui->pushButton->setEnabled(false);
21 | server.listen();
22 | }
23 |
24 | void MainWindow::on_pushButton_2_clicked()
25 | {
26 | server.close();
27 | this->ui->pushButton_2->setEnabled(false);
28 | this->ui->pushButton->setEnabled(true);
29 | }
30 |
--------------------------------------------------------------------------------
/test/msslserver/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include "testserver.h"
6 |
7 | namespace Ui {
8 | class MainWindow;
9 | }
10 |
11 | class MainWindow : public QMainWindow
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | explicit MainWindow(QWidget *parent = 0);
17 | ~MainWindow();
18 |
19 | private slots:
20 | void on_pushButton_clicked();
21 |
22 | void on_pushButton_2_clicked();
23 |
24 | private:
25 | TestServer server;
26 | Ui::MainWindow *ui;
27 | };
28 |
29 | #endif // MAINWINDOW_H
30 |
--------------------------------------------------------------------------------
/test/msslserver/mainwindow.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 50
21 | 80
22 | 75
23 | 23
24 |
25 |
26 |
27 | 启动
28 |
29 |
30 |
31 |
32 |
33 | 240
34 | 80
35 | 75
36 | 23
37 |
38 |
39 |
40 | 关闭
41 |
42 |
43 |
44 |
54 |
55 |
56 | TopToolBarArea
57 |
58 |
59 | false
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/test/msslserver/msslserver.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-07-30T15:30:06
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = msslserver
12 | TEMPLATE = app
13 | CONFIG += console
14 | DEFINES += QASIO_SSL
15 |
16 | CONFIG += c++11
17 |
18 | SOURCES += main.cpp\
19 | mainwindow.cpp \
20 | testserver.cpp
21 |
22 | HEADERS += mainwindow.h \
23 | testserver.h
24 |
25 | FORMS += mainwindow.ui
26 |
27 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocket
28 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocketd
29 | else:unix: LIBS += -L$$PWD/../../lib/ -lQAsioSocket
30 |
31 | INCLUDEPATH += $$PWD/../../include
32 | DEPENDPATH += $$PWD/../../include
33 |
34 |
--------------------------------------------------------------------------------
/test/msslserver/testserver.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTSERVER_H
2 | #define TESTSERVER_H
3 |
4 | #include
5 | #include "qasiosslserver.h"
6 | #include
7 | #include
8 | #include
9 |
10 | class TestServer : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit TestServer(QObject *parent = 0);
15 | ~TestServer();
16 |
17 | signals:
18 |
19 | public slots:
20 | void listen(qint16 port = 2048) {
21 | qDebug() << "Listen result:" << server.listen(port);// << std::endl;
22 | startTime = QTime::currentTime();
23 | qDebug() << "Start Time:" << startTime;
24 | }
25 | void close () {
26 | server.close();
27 | }
28 | protected slots:
29 | void newCon(QAsioSslSocket * socket);
30 | void readData(const QByteArray & data);
31 | private:
32 | QAsioSslServer server;
33 | QTime startTime;
34 | };
35 |
36 | class myClient : public QObject
37 | {
38 | Q_OBJECT
39 | public:
40 | explicit myClient(QAsioSslSocket * socket,QObject *parent = 0);
41 | ~myClient();
42 |
43 | int ID() const {return id;}
44 | protected slots:
45 | void readData(const QByteArray & data);
46 | void erroString(const QString & erro);
47 | void disConnected();
48 | private:
49 | QAsioSslSocket * soc;
50 | int id;
51 | };
52 |
53 | #endif // TESTSERVER_H
54 |
--------------------------------------------------------------------------------
/test/myserver/main.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | QApplication a(argc, argv);
7 | MainWindow w;
8 | w.show();
9 |
10 | return a.exec();
11 | }
12 |
--------------------------------------------------------------------------------
/test/myserver/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | #include "mainwindow.h"
2 | #include "ui_mainwindow.h"
3 |
4 | MainWindow::MainWindow(QWidget *parent) :
5 | QMainWindow(parent),
6 | ui(new Ui::MainWindow)
7 | {
8 | ui->setupUi(this);
9 | this->ui->pushButton_2->setEnabled(false);
10 | }
11 |
12 | MainWindow::~MainWindow()
13 | {
14 | delete ui;
15 | }
16 |
17 | void MainWindow::on_pushButton_clicked()
18 | {
19 | this->ui->pushButton_2->setEnabled(true);
20 | this->ui->pushButton->setEnabled(false);
21 | server.listen();
22 | }
23 |
24 | void MainWindow::on_pushButton_2_clicked()
25 | {
26 | server.close();
27 | this->ui->pushButton_2->setEnabled(false);
28 | this->ui->pushButton->setEnabled(true);
29 | }
30 |
--------------------------------------------------------------------------------
/test/myserver/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include "testserver.h"
6 |
7 | namespace Ui {
8 | class MainWindow;
9 | }
10 |
11 | class MainWindow : public QMainWindow
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | explicit MainWindow(QWidget *parent = 0);
17 | ~MainWindow();
18 |
19 | private slots:
20 | void on_pushButton_clicked();
21 |
22 | void on_pushButton_2_clicked();
23 |
24 | private:
25 | TestServer server;
26 | Ui::MainWindow *ui;
27 | };
28 |
29 | #endif // MAINWINDOW_H
30 |
--------------------------------------------------------------------------------
/test/myserver/mainwindow.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 50
21 | 80
22 | 75
23 | 23
24 |
25 |
26 |
27 | 启动
28 |
29 |
30 |
31 |
32 |
33 | 240
34 | 80
35 | 75
36 | 23
37 |
38 |
39 |
40 | 关闭
41 |
42 |
43 |
44 |
54 |
55 |
56 | TopToolBarArea
57 |
58 |
59 | false
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/test/myserver/myserver.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-07-30T15:30:06
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = msserver
12 | TEMPLATE = app
13 | CONFIG += console
14 |
15 | CONFIG += C++11
16 |
17 | SOURCES += main.cpp\
18 | mainwindow.cpp \
19 | testserver.cpp
20 |
21 | HEADERS += mainwindow.h \
22 | testserver.h
23 |
24 | FORMS += mainwindow.ui
25 |
26 |
27 | win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocket
28 | else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocketd
29 | else:unix: LIBS += -L$$PWD/../../lib/ -lQAsioSocket
30 |
31 | INCLUDEPATH += $$PWD/../../include
32 | DEPENDPATH += $$PWD/../../include
33 |
--------------------------------------------------------------------------------
/test/myserver/testserver.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTSERVER_H
2 | #define TESTSERVER_H
3 |
4 | #include
5 | #include "qasiotcpserver.h"
6 | #include
7 | #include
8 | #include
9 |
10 | class TestServer : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit TestServer(QObject *parent = 0);
15 | ~TestServer();
16 |
17 | signals:
18 |
19 | public slots:
20 | void listen(qint16 port = 2048) {
21 | qDebug() << "Listen result:" << server.listen(port);// << std::endl;
22 | startTime = QTime::currentTime();
23 | qDebug() << "Start Time:" << startTime;
24 | }
25 | void close() {
26 | server.close();
27 | }
28 | protected slots:
29 | void newCon(QAsioTcpsocket * socket);
30 | void readData(const QByteArray & data);
31 | private:
32 | QAsioTcpServer server;
33 | QTime startTime;
34 | };
35 |
36 | class myClient : public QObject
37 | {
38 | Q_OBJECT
39 | public:
40 | explicit myClient(QAsioTcpsocket * socket,QObject *parent = 0);
41 | ~myClient();
42 |
43 | int ID() const {return id;}
44 | protected slots:
45 | void readData(const QByteArray & data);
46 | void erroString(const QString & erro);
47 | void disConnected();
48 | private:
49 | QAsioTcpsocket * soc;
50 | int id;
51 | };
52 |
53 | #endif // TESTSERVER_H
54 |
--------------------------------------------------------------------------------
/test/server/server.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2014-12-08T16:04:57
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core
8 |
9 | QT -= gui
10 |
11 | TARGET = QAsioTcpServer
12 | CONFIG += console
13 | CONFIG -= app_bundle
14 |
15 | DEFINES += QASIOSOCKET_NOLIB
16 |
17 | include($$PWD/../../QAsioSocket.pri)
18 |
19 | SOURCES += main.cpp \
20 | testserver.cpp
21 |
22 | HEADERS += \
23 | testserver.h
24 |
25 |
26 |
27 | #win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocket
28 | #else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../lib/ -lQAsioSocketd
29 | #else:unix: LIBS += -L$$PWD/../../lib/ -lQAsioSocket
30 |
31 |
32 |
--------------------------------------------------------------------------------
/test/server/testserver.h:
--------------------------------------------------------------------------------
1 | #ifndef TESTSERVER_H
2 | #define TESTSERVER_H
3 |
4 | #include
5 | #include "qasiotcpserver.h"
6 | #include
7 | #include
8 | #include
9 |
10 | class TestServer : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit TestServer(QObject *parent = 0);
15 | ~TestServer();
16 |
17 | signals:
18 |
19 | public slots:
20 | void listen(qint16 port = 2048) {
21 | qDebug() << "Listen result:" << server.listen(port);// << std::endl;
22 | startTime = QTime::currentTime();
23 | qDebug() << "Start Time:" << startTime;
24 | }
25 | void close() {
26 | server.close();
27 | }
28 | protected slots:
29 | void newCon(QAsioTcpsocket * socket);
30 | void readData(const QByteArray & data);
31 | private:
32 | QAsioTcpServer server;
33 | QTime startTime;
34 | };
35 |
36 | class myClient : public QObject
37 | {
38 | Q_OBJECT
39 | public:
40 | explicit myClient(QAsioTcpsocket * socket,QObject *parent = 0);
41 | ~myClient();
42 |
43 | int ID() const {return id;}
44 | protected slots:
45 | void readData(const QByteArray & data);
46 | void erroString(const QString & erro);
47 | void disConnected();
48 | private:
49 | QAsioTcpsocket * soc;
50 | int id;
51 | };
52 |
53 | #endif // TESTSERVER_H
54 |
--------------------------------------------------------------------------------
/test/sslserver/Jamfile:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3 | #
4 | # Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | #
7 |
8 | subproject libs/asio/example/ssl ;
9 |
10 | project boost : $(BOOST_ROOT) ;
11 |
12 | if $(UNIX)
13 | {
14 | switch $(JAMUNAME)
15 | {
16 | case SunOS* :
17 | {
18 | SOCKET_LIBS = socket nsl ;
19 | }
20 | }
21 | }
22 |
23 | exe client
24 | : @boost/libs/system/build/boost_system
25 | client.cpp
26 | : $(BOOST_ROOT)
27 | ../../../..
28 | BOOST_ALL_NO_LIB=1
29 | multi
30 | ssl
31 | crypto
32 | <*>ws2_32
33 | <*>mswsock
34 | $(SOCKET_LIBS)
35 | ;
36 |
37 | exe server
38 | : @boost/libs/system/build/boost_system
39 | server.cpp
40 | : $(BOOST_ROOT)
41 | ../../../..
42 | BOOST_ALL_NO_LIB=1
43 | multi
44 | ssl
45 | crypto
46 | <*>ws2_32
47 | <*>mswsock
48 | $(SOCKET_LIBS)
49 | ;
50 |
--------------------------------------------------------------------------------
/test/sslserver/Jamfile.v2:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
3 | #
4 | # Distributed under the Boost Software License, Version 1.0. (See accompanying
5 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 | #
7 |
8 | import os ;
9 |
10 | if [ os.name ] = SOLARIS
11 | {
12 | lib socket ;
13 | lib nsl ;
14 | }
15 | else if [ os.name ] = NT
16 | {
17 | lib ws2_32 ;
18 | lib mswsock ;
19 | }
20 | else if [ os.name ] = HPUX
21 | {
22 | lib ipv6 ;
23 | }
24 |
25 | if [ os.name ] = NT
26 | {
27 | lib ssl : : ssleay32 ;
28 | lib crypto : : libeay32 ;
29 | }
30 | else
31 | {
32 | lib ssl ;
33 | lib crypto ;
34 | }
35 |
36 | project
37 | : requirements
38 | /boost/system//boost_system
39 | BOOST_ALL_NO_LIB=1
40 | multi
41 | SOLARIS:socket
42 | SOLARIS:nsl
43 | NT:_WIN32_WINNT=0x0501
44 | NT,