couchbase 3.0.3-universal-darwin-20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +131 -0
- data/ext/CMakeLists.txt +130 -0
- data/ext/LICENSE.txt +202 -0
- data/ext/build_config.hxx.in +22 -0
- data/ext/build_version.hxx.in +30 -0
- data/ext/cmake/Backtrace.cmake +35 -0
- data/ext/cmake/BuildTracing.cmake +6 -0
- data/ext/cmake/Cache.cmake +29 -0
- data/ext/cmake/CompilerWarnings.cmake +84 -0
- data/ext/cmake/PreventInSourceBuilds.cmake +21 -0
- data/ext/cmake/Sanitizers.cmake +66 -0
- data/ext/cmake/StandardProjectSettings.cmake +40 -0
- data/ext/cmake/StaticAnalyzers.cmake +37 -0
- data/ext/cmake/Testing.cmake +49 -0
- data/ext/cmake/ThirdPartyDependencies.cmake +20 -0
- data/ext/cmake/VersionInfo.cmake +37 -0
- data/ext/couchbase/bucket.hxx +372 -0
- data/ext/couchbase/capabilities.hxx +117 -0
- data/ext/couchbase/cbcrypto/cbcrypto.cc +888 -0
- data/ext/couchbase/cbcrypto/cbcrypto.h +89 -0
- data/ext/couchbase/cbsasl/client.cc +48 -0
- data/ext/couchbase/cbsasl/client.h +127 -0
- data/ext/couchbase/cbsasl/context.cc +33 -0
- data/ext/couchbase/cbsasl/context.h +52 -0
- data/ext/couchbase/cbsasl/error.h +72 -0
- data/ext/couchbase/cbsasl/mechanism.cc +48 -0
- data/ext/couchbase/cbsasl/mechanism.h +55 -0
- data/ext/couchbase/cbsasl/plain/plain.cc +36 -0
- data/ext/couchbase/cbsasl/plain/plain.h +53 -0
- data/ext/couchbase/cbsasl/scram-sha/scram-sha.cc +390 -0
- data/ext/couchbase/cbsasl/scram-sha/scram-sha.h +185 -0
- data/ext/couchbase/cbsasl/scram-sha/stringutils.cc +81 -0
- data/ext/couchbase/cbsasl/scram-sha/stringutils.h +48 -0
- data/ext/couchbase/cluster.hxx +356 -0
- data/ext/couchbase/cluster_options.hxx +54 -0
- data/ext/couchbase/collections_manifest.hxx +88 -0
- data/ext/couchbase/configuration.hxx +652 -0
- data/ext/couchbase/couchbase.cxx +8015 -0
- data/ext/couchbase/diagnostics.hxx +248 -0
- data/ext/couchbase/document_id.hxx +40 -0
- data/ext/couchbase/error_context/analytics.hxx +46 -0
- data/ext/couchbase/error_context/http.hxx +44 -0
- data/ext/couchbase/error_context/key_value.hxx +47 -0
- data/ext/couchbase/error_context/query.hxx +46 -0
- data/ext/couchbase/error_context/search.hxx +47 -0
- data/ext/couchbase/error_context/view.hxx +47 -0
- data/ext/couchbase/error_map.hxx +261 -0
- data/ext/couchbase/errors.hxx +706 -0
- data/ext/couchbase/io/dns_client.hxx +217 -0
- data/ext/couchbase/io/dns_codec.hxx +206 -0
- data/ext/couchbase/io/dns_config.hxx +116 -0
- data/ext/couchbase/io/dns_message.hxx +555 -0
- data/ext/couchbase/io/http_command.hxx +111 -0
- data/ext/couchbase/io/http_context.hxx +37 -0
- data/ext/couchbase/io/http_message.hxx +47 -0
- data/ext/couchbase/io/http_parser.hxx +176 -0
- data/ext/couchbase/io/http_session.hxx +444 -0
- data/ext/couchbase/io/http_session_manager.hxx +264 -0
- data/ext/couchbase/io/mcbp_command.hxx +249 -0
- data/ext/couchbase/io/mcbp_context.hxx +37 -0
- data/ext/couchbase/io/mcbp_message.hxx +63 -0
- data/ext/couchbase/io/mcbp_parser.hxx +101 -0
- data/ext/couchbase/io/mcbp_session.hxx +1350 -0
- data/ext/couchbase/io/query_cache.hxx +61 -0
- data/ext/couchbase/io/retry_action.hxx +30 -0
- data/ext/couchbase/io/retry_context.hxx +38 -0
- data/ext/couchbase/io/retry_orchestrator.hxx +112 -0
- data/ext/couchbase/io/retry_reason.hxx +235 -0
- data/ext/couchbase/io/retry_strategy.hxx +156 -0
- data/ext/couchbase/io/streams.hxx +216 -0
- data/ext/couchbase/mutation_token.hxx +38 -0
- data/ext/couchbase/operations.hxx +109 -0
- data/ext/couchbase/operations/analytics_dataset_create.hxx +125 -0
- data/ext/couchbase/operations/analytics_dataset_drop.hxx +112 -0
- data/ext/couchbase/operations/analytics_dataset_get_all.hxx +114 -0
- data/ext/couchbase/operations/analytics_dataverse_create.hxx +112 -0
- data/ext/couchbase/operations/analytics_dataverse_drop.hxx +111 -0
- data/ext/couchbase/operations/analytics_get_pending_mutations.hxx +99 -0
- data/ext/couchbase/operations/analytics_index_create.hxx +135 -0
- data/ext/couchbase/operations/analytics_index_drop.hxx +117 -0
- data/ext/couchbase/operations/analytics_index_get_all.hxx +113 -0
- data/ext/couchbase/operations/analytics_link_connect.hxx +109 -0
- data/ext/couchbase/operations/analytics_link_disconnect.hxx +108 -0
- data/ext/couchbase/operations/bucket_create.hxx +171 -0
- data/ext/couchbase/operations/bucket_drop.hxx +70 -0
- data/ext/couchbase/operations/bucket_flush.hxx +69 -0
- data/ext/couchbase/operations/bucket_get.hxx +78 -0
- data/ext/couchbase/operations/bucket_get_all.hxx +73 -0
- data/ext/couchbase/operations/bucket_settings.hxx +166 -0
- data/ext/couchbase/operations/bucket_update.hxx +147 -0
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +64 -0
- data/ext/couchbase/operations/collection_create.hxx +102 -0
- data/ext/couchbase/operations/collection_drop.hxx +92 -0
- data/ext/couchbase/operations/collections_manifest_get.hxx +66 -0
- data/ext/couchbase/operations/design_document.hxx +59 -0
- data/ext/couchbase/operations/document_analytics.hxx +316 -0
- data/ext/couchbase/operations/document_append.hxx +72 -0
- data/ext/couchbase/operations/document_decrement.hxx +83 -0
- data/ext/couchbase/operations/document_exists.hxx +83 -0
- data/ext/couchbase/operations/document_get.hxx +66 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +67 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +67 -0
- data/ext/couchbase/operations/document_get_projected.hxx +257 -0
- data/ext/couchbase/operations/document_increment.hxx +85 -0
- data/ext/couchbase/operations/document_insert.hxx +77 -0
- data/ext/couchbase/operations/document_lookup_in.hxx +112 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +151 -0
- data/ext/couchbase/operations/document_prepend.hxx +72 -0
- data/ext/couchbase/operations/document_query.hxx +440 -0
- data/ext/couchbase/operations/document_remove.hxx +72 -0
- data/ext/couchbase/operations/document_replace.hxx +79 -0
- data/ext/couchbase/operations/document_search.hxx +392 -0
- data/ext/couchbase/operations/document_touch.hxx +63 -0
- data/ext/couchbase/operations/document_unlock.hxx +63 -0
- data/ext/couchbase/operations/document_upsert.hxx +77 -0
- data/ext/couchbase/operations/document_view.hxx +245 -0
- data/ext/couchbase/operations/group_drop.hxx +72 -0
- data/ext/couchbase/operations/group_get.hxx +80 -0
- data/ext/couchbase/operations/group_get_all.hxx +77 -0
- data/ext/couchbase/operations/group_upsert.hxx +125 -0
- data/ext/couchbase/operations/http_noop.hxx +78 -0
- data/ext/couchbase/operations/mcbp_noop.hxx +55 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +93 -0
- data/ext/couchbase/operations/query_index_create.hxx +152 -0
- data/ext/couchbase/operations/query_index_drop.hxx +126 -0
- data/ext/couchbase/operations/query_index_get_all.hxx +124 -0
- data/ext/couchbase/operations/rbac.hxx +276 -0
- data/ext/couchbase/operations/role_get_all.hxx +77 -0
- data/ext/couchbase/operations/scope_create.hxx +95 -0
- data/ext/couchbase/operations/scope_drop.hxx +89 -0
- data/ext/couchbase/operations/scope_get_all.hxx +82 -0
- data/ext/couchbase/operations/search_get_stats.hxx +60 -0
- data/ext/couchbase/operations/search_index.hxx +79 -0
- data/ext/couchbase/operations/search_index_analyze_document.hxx +105 -0
- data/ext/couchbase/operations/search_index_control_ingest.hxx +93 -0
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +93 -0
- data/ext/couchbase/operations/search_index_control_query.hxx +93 -0
- data/ext/couchbase/operations/search_index_drop.hxx +90 -0
- data/ext/couchbase/operations/search_index_get.hxx +93 -0
- data/ext/couchbase/operations/search_index_get_all.hxx +89 -0
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +101 -0
- data/ext/couchbase/operations/search_index_get_stats.hxx +88 -0
- data/ext/couchbase/operations/search_index_upsert.hxx +119 -0
- data/ext/couchbase/operations/user_drop.hxx +73 -0
- data/ext/couchbase/operations/user_get.hxx +81 -0
- data/ext/couchbase/operations/user_get_all.hxx +78 -0
- data/ext/couchbase/operations/user_upsert.hxx +132 -0
- data/ext/couchbase/operations/view_index_drop.hxx +68 -0
- data/ext/couchbase/operations/view_index_get.hxx +97 -0
- data/ext/couchbase/operations/view_index_get_all.hxx +132 -0
- data/ext/couchbase/operations/view_index_upsert.hxx +88 -0
- data/ext/couchbase/origin.hxx +179 -0
- data/ext/couchbase/platform/backtrace.c +189 -0
- data/ext/couchbase/platform/backtrace.h +54 -0
- data/ext/couchbase/platform/base64.cc +234 -0
- data/ext/couchbase/platform/base64.h +47 -0
- data/ext/couchbase/platform/random.cc +119 -0
- data/ext/couchbase/platform/random.h +39 -0
- data/ext/couchbase/platform/string_hex.cc +99 -0
- data/ext/couchbase/platform/string_hex.h +50 -0
- data/ext/couchbase/platform/terminate_handler.cc +130 -0
- data/ext/couchbase/platform/terminate_handler.h +36 -0
- data/ext/couchbase/platform/uuid.cc +96 -0
- data/ext/couchbase/platform/uuid.h +56 -0
- data/ext/couchbase/protocol/client_opcode.hxx +632 -0
- data/ext/couchbase/protocol/client_request.hxx +161 -0
- data/ext/couchbase/protocol/client_response.hxx +221 -0
- data/ext/couchbase/protocol/cmd_append.hxx +145 -0
- data/ext/couchbase/protocol/cmd_cluster_map_change_notification.hxx +79 -0
- data/ext/couchbase/protocol/cmd_decrement.hxx +187 -0
- data/ext/couchbase/protocol/cmd_exists.hxx +172 -0
- data/ext/couchbase/protocol/cmd_get.hxx +122 -0
- data/ext/couchbase/protocol/cmd_get_and_lock.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_and_touch.hxx +142 -0
- data/ext/couchbase/protocol/cmd_get_cluster_config.hxx +126 -0
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +117 -0
- data/ext/couchbase/protocol/cmd_get_collections_manifest.hxx +99 -0
- data/ext/couchbase/protocol/cmd_get_error_map.hxx +126 -0
- data/ext/couchbase/protocol/cmd_hello.hxx +157 -0
- data/ext/couchbase/protocol/cmd_increment.hxx +187 -0
- data/ext/couchbase/protocol/cmd_info.hxx +25 -0
- data/ext/couchbase/protocol/cmd_insert.hxx +172 -0
- data/ext/couchbase/protocol/cmd_lookup_in.hxx +227 -0
- data/ext/couchbase/protocol/cmd_mutate_in.hxx +406 -0
- data/ext/couchbase/protocol/cmd_noop.hxx +82 -0
- data/ext/couchbase/protocol/cmd_prepend.hxx +145 -0
- data/ext/couchbase/protocol/cmd_remove.hxx +134 -0
- data/ext/couchbase/protocol/cmd_replace.hxx +172 -0
- data/ext/couchbase/protocol/cmd_sasl_auth.hxx +106 -0
- data/ext/couchbase/protocol/cmd_sasl_list_mechs.hxx +100 -0
- data/ext/couchbase/protocol/cmd_sasl_step.hxx +104 -0
- data/ext/couchbase/protocol/cmd_select_bucket.hxx +85 -0
- data/ext/couchbase/protocol/cmd_touch.hxx +102 -0
- data/ext/couchbase/protocol/cmd_unlock.hxx +95 -0
- data/ext/couchbase/protocol/cmd_upsert.hxx +172 -0
- data/ext/couchbase/protocol/datatype.hxx +48 -0
- data/ext/couchbase/protocol/durability_level.hxx +83 -0
- data/ext/couchbase/protocol/enhanced_error_info.hxx +28 -0
- data/ext/couchbase/protocol/frame_info_id.hxx +187 -0
- data/ext/couchbase/protocol/hello_feature.hxx +264 -0
- data/ext/couchbase/protocol/magic.hxx +83 -0
- data/ext/couchbase/protocol/server_opcode.hxx +57 -0
- data/ext/couchbase/protocol/server_request.hxx +122 -0
- data/ext/couchbase/protocol/status.hxx +343 -0
- data/ext/couchbase/protocol/unsigned_leb128.h +195 -0
- data/ext/couchbase/service_type.hxx +60 -0
- data/ext/couchbase/timeout_defaults.hxx +41 -0
- data/ext/couchbase/utils/byteswap.hxx +33 -0
- data/ext/couchbase/utils/connection_string.hxx +379 -0
- data/ext/couchbase/utils/crc32.hxx +48 -0
- data/ext/couchbase/utils/url_codec.hxx +225 -0
- data/ext/couchbase/version.hxx +38 -0
- data/ext/extconf.rb +98 -0
- data/ext/test/CMakeLists.txt +5 -0
- data/ext/test/test_helper.hxx +141 -0
- data/ext/test/test_helper_native.hxx +56 -0
- data/ext/test/test_helper_ruby.hxx +72 -0
- data/ext/test/test_native_binary_operations.cxx +186 -0
- data/ext/test/test_native_diagnostics.cxx +436 -0
- data/ext/test/test_native_trivial_crud.cxx +83 -0
- data/ext/test/test_ruby_trivial_crud.cxx +35 -0
- data/ext/test/test_ruby_trivial_query.cxx +34 -0
- data/ext/third_party/asio/asio/include/asio.hpp +182 -0
- data/ext/third_party/asio/asio/include/asio/any_io_executor.hpp +71 -0
- data/ext/third_party/asio/asio/include/asio/associated_allocator.hpp +125 -0
- data/ext/third_party/asio/asio/include/asio/associated_executor.hpp +166 -0
- data/ext/third_party/asio/asio/include/asio/async_result.hpp +582 -0
- data/ext/third_party/asio/asio/include/asio/awaitable.hpp +133 -0
- data/ext/third_party/asio/asio/include/asio/basic_datagram_socket.hpp +1215 -0
- data/ext/third_party/asio/asio/include/asio/basic_deadline_timer.hpp +693 -0
- data/ext/third_party/asio/asio/include/asio/basic_io_object.hpp +290 -0
- data/ext/third_party/asio/asio/include/asio/basic_raw_socket.hpp +1206 -0
- data/ext/third_party/asio/asio/include/asio/basic_seq_packet_socket.hpp +761 -0
- data/ext/third_party/asio/asio/include/asio/basic_serial_port.hpp +907 -0
- data/ext/third_party/asio/asio/include/asio/basic_signal_set.hpp +568 -0
- data/ext/third_party/asio/asio/include/asio/basic_socket.hpp +1894 -0
- data/ext/third_party/asio/asio/include/asio/basic_socket_acceptor.hpp +2501 -0
- data/ext/third_party/asio/asio/include/asio/basic_socket_iostream.hpp +407 -0
- data/ext/third_party/asio/asio/include/asio/basic_socket_streambuf.hpp +687 -0
- data/ext/third_party/asio/asio/include/asio/basic_stream_socket.hpp +1053 -0
- data/ext/third_party/asio/asio/include/asio/basic_streambuf.hpp +452 -0
- data/ext/third_party/asio/asio/include/asio/basic_streambuf_fwd.hpp +36 -0
- data/ext/third_party/asio/asio/include/asio/basic_waitable_timer.hpp +811 -0
- data/ext/third_party/asio/asio/include/asio/bind_executor.hpp +575 -0
- data/ext/third_party/asio/asio/include/asio/buffer.hpp +2496 -0
- data/ext/third_party/asio/asio/include/asio/buffered_read_stream.hpp +253 -0
- data/ext/third_party/asio/asio/include/asio/buffered_read_stream_fwd.hpp +25 -0
- data/ext/third_party/asio/asio/include/asio/buffered_stream.hpp +279 -0
- data/ext/third_party/asio/asio/include/asio/buffered_stream_fwd.hpp +25 -0
- data/ext/third_party/asio/asio/include/asio/buffered_write_stream.hpp +245 -0
- data/ext/third_party/asio/asio/include/asio/buffered_write_stream_fwd.hpp +25 -0
- data/ext/third_party/asio/asio/include/asio/buffers_iterator.hpp +521 -0
- data/ext/third_party/asio/asio/include/asio/co_spawn.hpp +471 -0
- data/ext/third_party/asio/asio/include/asio/completion_condition.hpp +218 -0
- data/ext/third_party/asio/asio/include/asio/compose.hpp +136 -0
- data/ext/third_party/asio/asio/include/asio/connect.hpp +1076 -0
- data/ext/third_party/asio/asio/include/asio/coroutine.hpp +328 -0
- data/ext/third_party/asio/asio/include/asio/deadline_timer.hpp +38 -0
- data/ext/third_party/asio/asio/include/asio/defer.hpp +130 -0
- data/ext/third_party/asio/asio/include/asio/detached.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/detail/array.hpp +38 -0
- data/ext/third_party/asio/asio/include/asio/detail/array_fwd.hpp +34 -0
- data/ext/third_party/asio/asio/include/asio/detail/assert.hpp +32 -0
- data/ext/third_party/asio/asio/include/asio/detail/atomic_count.hpp +64 -0
- data/ext/third_party/asio/asio/include/asio/detail/base_from_completion_cond.hpp +69 -0
- data/ext/third_party/asio/asio/include/asio/detail/bind_handler.hpp +934 -0
- data/ext/third_party/asio/asio/include/asio/detail/blocking_executor_op.hpp +107 -0
- data/ext/third_party/asio/asio/include/asio/detail/buffer_resize_guard.hpp +66 -0
- data/ext/third_party/asio/asio/include/asio/detail/buffer_sequence_adapter.hpp +650 -0
- data/ext/third_party/asio/asio/include/asio/detail/buffered_stream_storage.hpp +126 -0
- data/ext/third_party/asio/asio/include/asio/detail/bulk_executor_op.hpp +88 -0
- data/ext/third_party/asio/asio/include/asio/detail/call_stack.hpp +125 -0
- data/ext/third_party/asio/asio/include/asio/detail/chrono.hpp +66 -0
- data/ext/third_party/asio/asio/include/asio/detail/chrono_time_traits.hpp +190 -0
- data/ext/third_party/asio/asio/include/asio/detail/completion_handler.hpp +88 -0
- data/ext/third_party/asio/asio/include/asio/detail/concurrency_hint.hpp +94 -0
- data/ext/third_party/asio/asio/include/asio/detail/conditionally_enabled_event.hpp +120 -0
- data/ext/third_party/asio/asio/include/asio/detail/conditionally_enabled_mutex.hpp +149 -0
- data/ext/third_party/asio/asio/include/asio/detail/config.hpp +1822 -0
- data/ext/third_party/asio/asio/include/asio/detail/consuming_buffers.hpp +414 -0
- data/ext/third_party/asio/asio/include/asio/detail/cstddef.hpp +31 -0
- data/ext/third_party/asio/asio/include/asio/detail/cstdint.hpp +60 -0
- data/ext/third_party/asio/asio/include/asio/detail/date_time_fwd.hpp +34 -0
- data/ext/third_party/asio/asio/include/asio/detail/deadline_timer_service.hpp +295 -0
- data/ext/third_party/asio/asio/include/asio/detail/dependent_type.hpp +36 -0
- data/ext/third_party/asio/asio/include/asio/detail/descriptor_ops.hpp +139 -0
- data/ext/third_party/asio/asio/include/asio/detail/descriptor_read_op.hpp +148 -0
- data/ext/third_party/asio/asio/include/asio/detail/descriptor_write_op.hpp +148 -0
- data/ext/third_party/asio/asio/include/asio/detail/dev_poll_reactor.hpp +218 -0
- data/ext/third_party/asio/asio/include/asio/detail/epoll_reactor.hpp +266 -0
- data/ext/third_party/asio/asio/include/asio/detail/event.hpp +48 -0
- data/ext/third_party/asio/asio/include/asio/detail/eventfd_select_interrupter.hpp +83 -0
- data/ext/third_party/asio/asio/include/asio/detail/executor_function.hpp +203 -0
- data/ext/third_party/asio/asio/include/asio/detail/executor_op.hpp +84 -0
- data/ext/third_party/asio/asio/include/asio/detail/fd_set_adapter.hpp +39 -0
- data/ext/third_party/asio/asio/include/asio/detail/fenced_block.hpp +80 -0
- data/ext/third_party/asio/asio/include/asio/detail/functional.hpp +38 -0
- data/ext/third_party/asio/asio/include/asio/detail/future.hpp +33 -0
- data/ext/third_party/asio/asio/include/asio/detail/gcc_arm_fenced_block.hpp +91 -0
- data/ext/third_party/asio/asio/include/asio/detail/gcc_hppa_fenced_block.hpp +68 -0
- data/ext/third_party/asio/asio/include/asio/detail/gcc_sync_fenced_block.hpp +65 -0
- data/ext/third_party/asio/asio/include/asio/detail/gcc_x86_fenced_block.hpp +99 -0
- data/ext/third_party/asio/asio/include/asio/detail/global.hpp +52 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_alloc_helpers.hpp +284 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_cont_helpers.hpp +45 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_invoke_helpers.hpp +80 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_tracking.hpp +264 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_type_requirements.hpp +556 -0
- data/ext/third_party/asio/asio/include/asio/detail/handler_work.hpp +438 -0
- data/ext/third_party/asio/asio/include/asio/detail/hash_map.hpp +331 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/buffer_sequence_adapter.ipp +118 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/descriptor_ops.ipp +608 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/dev_poll_reactor.hpp +91 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/dev_poll_reactor.ipp +446 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/epoll_reactor.hpp +89 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/epoll_reactor.ipp +787 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/eventfd_select_interrupter.ipp +169 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/handler_tracking.ipp +396 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/kqueue_reactor.hpp +93 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/kqueue_reactor.ipp +570 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/null_event.ipp +74 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/pipe_select_interrupter.ipp +129 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/posix_event.ipp +59 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/posix_mutex.ipp +46 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/posix_thread.ipp +84 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/posix_tss_ptr.ipp +46 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/reactive_descriptor_service.ipp +223 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/reactive_serial_port_service.ipp +149 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/reactive_socket_service_base.ipp +300 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/resolver_service_base.ipp +158 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/scheduler.ipp +654 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/select_reactor.hpp +100 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/select_reactor.ipp +338 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/service_registry.hpp +94 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/service_registry.ipp +197 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/signal_set_service.ipp +668 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/socket_ops.ipp +3962 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/socket_select_interrupter.ipp +185 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/strand_executor_service.hpp +385 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/strand_executor_service.ipp +134 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/strand_service.hpp +117 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/strand_service.ipp +178 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/throw_error.ipp +60 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/timer_queue_ptime.ipp +91 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/timer_queue_set.ipp +101 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_event.ipp +76 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_handle_service.ipp +525 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_io_context.hpp +103 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_io_context.ipp +603 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_serial_port_service.ipp +192 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_iocp_socket_service_base.ipp +801 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_mutex.ipp +84 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_object_handle_service.ipp +448 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_static_mutex.ipp +136 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_thread.ipp +150 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/win_tss_ptr.ipp +57 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/winrt_ssocket_service_base.ipp +626 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/winrt_timer_scheduler.hpp +92 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/winrt_timer_scheduler.ipp +121 -0
- data/ext/third_party/asio/asio/include/asio/detail/impl/winsock_init.ipp +82 -0
- data/ext/third_party/asio/asio/include/asio/detail/io_control.hpp +84 -0
- data/ext/third_party/asio/asio/include/asio/detail/io_object_impl.hpp +175 -0
- data/ext/third_party/asio/asio/include/asio/detail/is_buffer_sequence.hpp +312 -0
- data/ext/third_party/asio/asio/include/asio/detail/is_executor.hpp +126 -0
- data/ext/third_party/asio/asio/include/asio/detail/keyword_tss_ptr.hpp +70 -0
- data/ext/third_party/asio/asio/include/asio/detail/kqueue_reactor.hpp +242 -0
- data/ext/third_party/asio/asio/include/asio/detail/limits.hpp +26 -0
- data/ext/third_party/asio/asio/include/asio/detail/local_free_on_block_exit.hpp +59 -0
- data/ext/third_party/asio/asio/include/asio/detail/macos_fenced_block.hpp +62 -0
- data/ext/third_party/asio/asio/include/asio/detail/memory.hpp +73 -0
- data/ext/third_party/asio/asio/include/asio/detail/mutex.hpp +48 -0
- data/ext/third_party/asio/asio/include/asio/detail/non_const_lvalue.hpp +54 -0
- data/ext/third_party/asio/asio/include/asio/detail/noncopyable.hpp +43 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_event.hpp +106 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_fenced_block.hpp +47 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_global.hpp +59 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_mutex.hpp +64 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_reactor.hpp +68 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_signal_blocker.hpp +69 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_socket_service.hpp +519 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_static_mutex.hpp +60 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_thread.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/detail/null_tss_ptr.hpp +68 -0
- data/ext/third_party/asio/asio/include/asio/detail/object_pool.hpp +171 -0
- data/ext/third_party/asio/asio/include/asio/detail/old_win_sdk_compat.hpp +214 -0
- data/ext/third_party/asio/asio/include/asio/detail/op_queue.hpp +162 -0
- data/ext/third_party/asio/asio/include/asio/detail/operation.hpp +38 -0
- data/ext/third_party/asio/asio/include/asio/detail/pipe_select_interrupter.hpp +89 -0
- data/ext/third_party/asio/asio/include/asio/detail/pop_options.hpp +141 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_event.hpp +175 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_fd_set_adapter.hpp +118 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_global.hpp +80 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_mutex.hpp +76 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_signal_blocker.hpp +85 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_static_mutex.hpp +64 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_thread.hpp +109 -0
- data/ext/third_party/asio/asio/include/asio/detail/posix_tss_ptr.hpp +79 -0
- data/ext/third_party/asio/asio/include/asio/detail/push_options.hpp +185 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_descriptor_service.hpp +416 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_null_buffers_op.hpp +98 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_serial_port_service.hpp +237 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_accept_op.hpp +242 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_connect_op.hpp +123 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recv_op.hpp +159 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp +164 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp +145 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_send_op.hpp +162 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_sendto_op.hpp +156 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_service.hpp +528 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_socket_service_base.hpp +541 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactive_wait_op.hpp +98 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactor.hpp +32 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactor_fwd.hpp +40 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactor_op.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/detail/reactor_op_queue.hpp +168 -0
- data/ext/third_party/asio/asio/include/asio/detail/recycling_allocator.hpp +106 -0
- data/ext/third_party/asio/asio/include/asio/detail/regex_fwd.hpp +35 -0
- data/ext/third_party/asio/asio/include/asio/detail/resolve_endpoint_op.hpp +140 -0
- data/ext/third_party/asio/asio/include/asio/detail/resolve_op.hpp +45 -0
- data/ext/third_party/asio/asio/include/asio/detail/resolve_query_op.hpp +150 -0
- data/ext/third_party/asio/asio/include/asio/detail/resolver_service.hpp +145 -0
- data/ext/third_party/asio/asio/include/asio/detail/resolver_service_base.hpp +143 -0
- data/ext/third_party/asio/asio/include/asio/detail/scheduler.hpp +232 -0
- data/ext/third_party/asio/asio/include/asio/detail/scheduler_operation.hpp +78 -0
- data/ext/third_party/asio/asio/include/asio/detail/scheduler_thread_info.hpp +40 -0
- data/ext/third_party/asio/asio/include/asio/detail/scoped_lock.hpp +101 -0
- data/ext/third_party/asio/asio/include/asio/detail/scoped_ptr.hpp +87 -0
- data/ext/third_party/asio/asio/include/asio/detail/select_interrupter.hpp +46 -0
- data/ext/third_party/asio/asio/include/asio/detail/select_reactor.hpp +238 -0
- data/ext/third_party/asio/asio/include/asio/detail/service_registry.hpp +164 -0
- data/ext/third_party/asio/asio/include/asio/detail/signal_blocker.hpp +44 -0
- data/ext/third_party/asio/asio/include/asio/detail/signal_handler.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/detail/signal_init.hpp +47 -0
- data/ext/third_party/asio/asio/include/asio/detail/signal_op.hpp +49 -0
- data/ext/third_party/asio/asio/include/asio/detail/signal_set_service.hpp +229 -0
- data/ext/third_party/asio/asio/include/asio/detail/socket_holder.hpp +98 -0
- data/ext/third_party/asio/asio/include/asio/detail/socket_ops.hpp +383 -0
- data/ext/third_party/asio/asio/include/asio/detail/socket_option.hpp +316 -0
- data/ext/third_party/asio/asio/include/asio/detail/socket_select_interrupter.hpp +91 -0
- data/ext/third_party/asio/asio/include/asio/detail/socket_types.hpp +416 -0
- data/ext/third_party/asio/asio/include/asio/detail/solaris_fenced_block.hpp +62 -0
- data/ext/third_party/asio/asio/include/asio/detail/source_location.hpp +45 -0
- data/ext/third_party/asio/asio/include/asio/detail/static_mutex.hpp +52 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_event.hpp +188 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_fenced_block.hpp +62 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_global.hpp +70 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_mutex.hpp +73 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_static_mutex.hpp +81 -0
- data/ext/third_party/asio/asio/include/asio/detail/std_thread.hpp +71 -0
- data/ext/third_party/asio/asio/include/asio/detail/strand_executor_service.hpp +166 -0
- data/ext/third_party/asio/asio/include/asio/detail/strand_service.hpp +145 -0
- data/ext/third_party/asio/asio/include/asio/detail/string_view.hpp +47 -0
- data/ext/third_party/asio/asio/include/asio/detail/thread.hpp +60 -0
- data/ext/third_party/asio/asio/include/asio/detail/thread_context.hpp +42 -0
- data/ext/third_party/asio/asio/include/asio/detail/thread_group.hpp +95 -0
- data/ext/third_party/asio/asio/include/asio/detail/thread_info_base.hpp +183 -0
- data/ext/third_party/asio/asio/include/asio/detail/throw_error.hpp +53 -0
- data/ext/third_party/asio/asio/include/asio/detail/throw_exception.hpp +51 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_queue.hpp +360 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_queue_base.hpp +68 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_queue_ptime.hpp +99 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_queue_set.hpp +66 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_scheduler.hpp +35 -0
- data/ext/third_party/asio/asio/include/asio/detail/timer_scheduler_fwd.hpp +40 -0
- data/ext/third_party/asio/asio/include/asio/detail/tss_ptr.hpp +69 -0
- data/ext/third_party/asio/asio/include/asio/detail/type_traits.hpp +148 -0
- data/ext/third_party/asio/asio/include/asio/detail/variadic_templates.hpp +294 -0
- data/ext/third_party/asio/asio/include/asio/detail/wait_handler.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/detail/wait_op.hpp +45 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_event.hpp +164 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_fd_set_adapter.hpp +149 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_fenced_block.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_global.hpp +71 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_handle_read_op.hpp +117 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_handle_service.hpp +335 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_handle_write_op.hpp +110 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_io_context.hpp +342 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_null_buffers_op.hpp +127 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_operation.hpp +96 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_overlapped_op.hpp +96 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_overlapped_ptr.hpp +171 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_serial_port_service.hpp +232 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_accept_op.hpp +312 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_connect_op.hpp +135 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recv_op.hpp +124 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recvfrom_op.hpp +133 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_recvmsg_op.hpp +125 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_send_op.hpp +118 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_service.hpp +581 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_socket_service_base.hpp +600 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_thread_info.hpp +34 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_iocp_wait_op.hpp +128 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_mutex.hpp +78 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_object_handle_service.hpp +195 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_static_mutex.hpp +74 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_thread.hpp +147 -0
- data/ext/third_party/asio/asio/include/asio/detail/win_tss_ptr.hpp +79 -0
- data/ext/third_party/asio/asio/include/asio/detail/winapp_thread.hpp +124 -0
- data/ext/third_party/asio/asio/include/asio/detail/wince_thread.hpp +124 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_async_manager.hpp +305 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_async_op.hpp +65 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_resolve_op.hpp +125 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_resolver_service.hpp +212 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_connect_op.hpp +98 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_recv_op.hpp +119 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_socket_send_op.hpp +110 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_ssocket_service.hpp +250 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_ssocket_service_base.hpp +362 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_timer_scheduler.hpp +147 -0
- data/ext/third_party/asio/asio/include/asio/detail/winrt_utils.hpp +106 -0
- data/ext/third_party/asio/asio/include/asio/detail/winsock_init.hpp +128 -0
- data/ext/third_party/asio/asio/include/asio/detail/work_dispatcher.hpp +148 -0
- data/ext/third_party/asio/asio/include/asio/detail/wrapped_handler.hpp +327 -0
- data/ext/third_party/asio/asio/include/asio/dispatch.hpp +121 -0
- data/ext/third_party/asio/asio/include/asio/error.hpp +356 -0
- data/ext/third_party/asio/asio/include/asio/error_code.hpp +202 -0
- data/ext/third_party/asio/asio/include/asio/execution.hpp +48 -0
- data/ext/third_party/asio/asio/include/asio/execution/allocator.hpp +249 -0
- data/ext/third_party/asio/asio/include/asio/execution/any_executor.hpp +2264 -0
- data/ext/third_party/asio/asio/include/asio/execution/bad_executor.hpp +47 -0
- data/ext/third_party/asio/asio/include/asio/execution/blocking.hpp +1351 -0
- data/ext/third_party/asio/asio/include/asio/execution/blocking_adaptation.hpp +1064 -0
- data/ext/third_party/asio/asio/include/asio/execution/bulk_execute.hpp +390 -0
- data/ext/third_party/asio/asio/include/asio/execution/bulk_guarantee.hpp +1018 -0
- data/ext/third_party/asio/asio/include/asio/execution/connect.hpp +486 -0
- data/ext/third_party/asio/asio/include/asio/execution/context.hpp +185 -0
- data/ext/third_party/asio/asio/include/asio/execution/context_as.hpp +201 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/as_invocable.hpp +152 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/as_operation.hpp +105 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/as_receiver.hpp +128 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/bulk_sender.hpp +261 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/submit_receiver.hpp +233 -0
- data/ext/third_party/asio/asio/include/asio/execution/detail/void_receiver.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/execution/execute.hpp +264 -0
- data/ext/third_party/asio/asio/include/asio/execution/executor.hpp +238 -0
- data/ext/third_party/asio/asio/include/asio/execution/impl/bad_executor.ipp +40 -0
- data/ext/third_party/asio/asio/include/asio/execution/impl/receiver_invocation_error.ipp +36 -0
- data/ext/third_party/asio/asio/include/asio/execution/invocable_archetype.hpp +71 -0
- data/ext/third_party/asio/asio/include/asio/execution/mapping.hpp +917 -0
- data/ext/third_party/asio/asio/include/asio/execution/occupancy.hpp +178 -0
- data/ext/third_party/asio/asio/include/asio/execution/operation_state.hpp +94 -0
- data/ext/third_party/asio/asio/include/asio/execution/outstanding_work.hpp +721 -0
- data/ext/third_party/asio/asio/include/asio/execution/prefer_only.hpp +327 -0
- data/ext/third_party/asio/asio/include/asio/execution/receiver.hpp +280 -0
- data/ext/third_party/asio/asio/include/asio/execution/receiver_invocation_error.hpp +48 -0
- data/ext/third_party/asio/asio/include/asio/execution/relationship.hpp +720 -0
- data/ext/third_party/asio/asio/include/asio/execution/schedule.hpp +290 -0
- data/ext/third_party/asio/asio/include/asio/execution/scheduler.hpp +86 -0
- data/ext/third_party/asio/asio/include/asio/execution/sender.hpp +311 -0
- data/ext/third_party/asio/asio/include/asio/execution/set_done.hpp +253 -0
- data/ext/third_party/asio/asio/include/asio/execution/set_error.hpp +253 -0
- data/ext/third_party/asio/asio/include/asio/execution/set_value.hpp +486 -0
- data/ext/third_party/asio/asio/include/asio/execution/start.hpp +250 -0
- data/ext/third_party/asio/asio/include/asio/execution/submit.hpp +450 -0
- data/ext/third_party/asio/asio/include/asio/execution_context.hpp +412 -0
- data/ext/third_party/asio/asio/include/asio/executor.hpp +347 -0
- data/ext/third_party/asio/asio/include/asio/executor_work_guard.hpp +287 -0
- data/ext/third_party/asio/asio/include/asio/generic/basic_endpoint.hpp +193 -0
- data/ext/third_party/asio/asio/include/asio/generic/datagram_protocol.hpp +123 -0
- data/ext/third_party/asio/asio/include/asio/generic/detail/endpoint.hpp +133 -0
- data/ext/third_party/asio/asio/include/asio/generic/detail/impl/endpoint.ipp +110 -0
- data/ext/third_party/asio/asio/include/asio/generic/raw_protocol.hpp +121 -0
- data/ext/third_party/asio/asio/include/asio/generic/seq_packet_protocol.hpp +122 -0
- data/ext/third_party/asio/asio/include/asio/generic/stream_protocol.hpp +127 -0
- data/ext/third_party/asio/asio/include/asio/handler_alloc_hook.hpp +104 -0
- data/ext/third_party/asio/asio/include/asio/handler_continuation_hook.hpp +54 -0
- data/ext/third_party/asio/asio/include/asio/handler_invoke_hook.hpp +111 -0
- data/ext/third_party/asio/asio/include/asio/high_resolution_timer.hpp +44 -0
- data/ext/third_party/asio/asio/include/asio/impl/awaitable.hpp +436 -0
- data/ext/third_party/asio/asio/include/asio/impl/buffered_read_stream.hpp +527 -0
- data/ext/third_party/asio/asio/include/asio/impl/buffered_write_stream.hpp +507 -0
- data/ext/third_party/asio/asio/include/asio/impl/co_spawn.hpp +298 -0
- data/ext/third_party/asio/asio/include/asio/impl/compose.hpp +635 -0
- data/ext/third_party/asio/asio/include/asio/impl/connect.hpp +916 -0
- data/ext/third_party/asio/asio/include/asio/impl/defer.hpp +248 -0
- data/ext/third_party/asio/asio/include/asio/impl/detached.hpp +130 -0
- data/ext/third_party/asio/asio/include/asio/impl/dispatch.hpp +243 -0
- data/ext/third_party/asio/asio/include/asio/impl/error.ipp +128 -0
- data/ext/third_party/asio/asio/include/asio/impl/error_code.ipp +206 -0
- data/ext/third_party/asio/asio/include/asio/impl/execution_context.hpp +109 -0
- data/ext/third_party/asio/asio/include/asio/impl/execution_context.ipp +82 -0
- data/ext/third_party/asio/asio/include/asio/impl/executor.hpp +301 -0
- data/ext/third_party/asio/asio/include/asio/impl/executor.ipp +43 -0
- data/ext/third_party/asio/asio/include/asio/impl/handler_alloc_hook.ipp +61 -0
- data/ext/third_party/asio/asio/include/asio/impl/io_context.hpp +440 -0
- data/ext/third_party/asio/asio/include/asio/impl/io_context.ipp +175 -0
- data/ext/third_party/asio/asio/include/asio/impl/multiple_exceptions.ipp +49 -0
- data/ext/third_party/asio/asio/include/asio/impl/post.hpp +248 -0
- data/ext/third_party/asio/asio/include/asio/impl/read.hpp +1202 -0
- data/ext/third_party/asio/asio/include/asio/impl/read_at.hpp +744 -0
- data/ext/third_party/asio/asio/include/asio/impl/read_until.hpp +3335 -0
- data/ext/third_party/asio/asio/include/asio/impl/redirect_error.hpp +390 -0
- data/ext/third_party/asio/asio/include/asio/impl/serial_port_base.hpp +59 -0
- data/ext/third_party/asio/asio/include/asio/impl/serial_port_base.ipp +554 -0
- data/ext/third_party/asio/asio/include/asio/impl/spawn.hpp +526 -0
- data/ext/third_party/asio/asio/include/asio/impl/src.hpp +85 -0
- data/ext/third_party/asio/asio/include/asio/impl/system_context.hpp +34 -0
- data/ext/third_party/asio/asio/include/asio/impl/system_context.ipp +92 -0
- data/ext/third_party/asio/asio/include/asio/impl/system_executor.hpp +186 -0
- data/ext/third_party/asio/asio/include/asio/impl/thread_pool.hpp +350 -0
- data/ext/third_party/asio/asio/include/asio/impl/thread_pool.ipp +141 -0
- data/ext/third_party/asio/asio/include/asio/impl/use_awaitable.hpp +279 -0
- data/ext/third_party/asio/asio/include/asio/impl/use_future.hpp +1028 -0
- data/ext/third_party/asio/asio/include/asio/impl/write.hpp +1104 -0
- data/ext/third_party/asio/asio/include/asio/impl/write_at.hpp +666 -0
- data/ext/third_party/asio/asio/include/asio/io_context.hpp +1530 -0
- data/ext/third_party/asio/asio/include/asio/io_context_strand.hpp +376 -0
- data/ext/third_party/asio/asio/include/asio/io_service.hpp +33 -0
- data/ext/third_party/asio/asio/include/asio/io_service_strand.hpp +20 -0
- data/ext/third_party/asio/asio/include/asio/ip/address.hpp +268 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v4.hpp +335 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v4_iterator.hpp +162 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v4_range.hpp +134 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v6.hpp +341 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v6_iterator.hpp +183 -0
- data/ext/third_party/asio/asio/include/asio/ip/address_v6_range.hpp +129 -0
- data/ext/third_party/asio/asio/include/asio/ip/bad_address_cast.hpp +53 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_endpoint.hpp +264 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_resolver.hpp +1030 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_resolver_entry.hpp +113 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_resolver_iterator.hpp +192 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_resolver_query.hpp +244 -0
- data/ext/third_party/asio/asio/include/asio/ip/basic_resolver_results.hpp +311 -0
- data/ext/third_party/asio/asio/include/asio/ip/detail/endpoint.hpp +141 -0
- data/ext/third_party/asio/asio/include/asio/ip/detail/impl/endpoint.ipp +199 -0
- data/ext/third_party/asio/asio/include/asio/ip/detail/socket_option.hpp +566 -0
- data/ext/third_party/asio/asio/include/asio/ip/host_name.hpp +42 -0
- data/ext/third_party/asio/asio/include/asio/ip/icmp.hpp +115 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address.ipp +239 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address_v4.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address_v4.ipp +210 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address_v6.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/address_v6.ipp +350 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/basic_endpoint.hpp +43 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/host_name.ipp +54 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/network_v4.hpp +54 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/network_v4.ipp +216 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/network_v6.hpp +53 -0
- data/ext/third_party/asio/asio/include/asio/ip/impl/network_v6.ipp +185 -0
- data/ext/third_party/asio/asio/include/asio/ip/multicast.hpp +191 -0
- data/ext/third_party/asio/asio/include/asio/ip/network_v4.hpp +261 -0
- data/ext/third_party/asio/asio/include/asio/ip/network_v6.hpp +235 -0
- data/ext/third_party/asio/asio/include/asio/ip/resolver_base.hpp +129 -0
- data/ext/third_party/asio/asio/include/asio/ip/resolver_query_base.hpp +43 -0
- data/ext/third_party/asio/asio/include/asio/ip/tcp.hpp +155 -0
- data/ext/third_party/asio/asio/include/asio/ip/udp.hpp +111 -0
- data/ext/third_party/asio/asio/include/asio/ip/unicast.hpp +70 -0
- data/ext/third_party/asio/asio/include/asio/ip/v6_only.hpp +69 -0
- data/ext/third_party/asio/asio/include/asio/is_applicable_property.hpp +61 -0
- data/ext/third_party/asio/asio/include/asio/is_executor.hpp +46 -0
- data/ext/third_party/asio/asio/include/asio/is_read_buffered.hpp +59 -0
- data/ext/third_party/asio/asio/include/asio/is_write_buffered.hpp +59 -0
- data/ext/third_party/asio/asio/include/asio/local/basic_endpoint.hpp +247 -0
- data/ext/third_party/asio/asio/include/asio/local/connect_pair.hpp +101 -0
- data/ext/third_party/asio/asio/include/asio/local/datagram_protocol.hpp +80 -0
- data/ext/third_party/asio/asio/include/asio/local/detail/endpoint.hpp +139 -0
- data/ext/third_party/asio/asio/include/asio/local/detail/impl/endpoint.ipp +136 -0
- data/ext/third_party/asio/asio/include/asio/local/stream_protocol.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/multiple_exceptions.hpp +58 -0
- data/ext/third_party/asio/asio/include/asio/packaged_task.hpp +126 -0
- data/ext/third_party/asio/asio/include/asio/placeholders.hpp +151 -0
- data/ext/third_party/asio/asio/include/asio/posix/basic_descriptor.hpp +697 -0
- data/ext/third_party/asio/asio/include/asio/posix/basic_stream_descriptor.hpp +470 -0
- data/ext/third_party/asio/asio/include/asio/posix/descriptor.hpp +37 -0
- data/ext/third_party/asio/asio/include/asio/posix/descriptor_base.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/posix/stream_descriptor.hpp +37 -0
- data/ext/third_party/asio/asio/include/asio/post.hpp +126 -0
- data/ext/third_party/asio/asio/include/asio/prefer.hpp +656 -0
- data/ext/third_party/asio/asio/include/asio/query.hpp +296 -0
- data/ext/third_party/asio/asio/include/asio/read.hpp +1288 -0
- data/ext/third_party/asio/asio/include/asio/read_at.hpp +694 -0
- data/ext/third_party/asio/asio/include/asio/read_until.hpp +2863 -0
- data/ext/third_party/asio/asio/include/asio/redirect_error.hpp +66 -0
- data/ext/third_party/asio/asio/include/asio/require.hpp +524 -0
- data/ext/third_party/asio/asio/include/asio/require_concept.hpp +310 -0
- data/ext/third_party/asio/asio/include/asio/serial_port.hpp +36 -0
- data/ext/third_party/asio/asio/include/asio/serial_port_base.hpp +167 -0
- data/ext/third_party/asio/asio/include/asio/signal_set.hpp +28 -0
- data/ext/third_party/asio/asio/include/asio/socket_base.hpp +559 -0
- data/ext/third_party/asio/asio/include/asio/spawn.hpp +344 -0
- data/ext/third_party/asio/asio/include/asio/ssl.hpp +28 -0
- data/ext/third_party/asio/asio/include/asio/ssl/context.hpp +761 -0
- data/ext/third_party/asio/asio/include/asio/ssl/context_base.hpp +209 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/buffered_handshake_op.hpp +119 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/engine.hpp +165 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/handshake_op.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/impl/engine.ipp +349 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/impl/openssl_init.ipp +165 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/io.hpp +415 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/openssl_init.hpp +101 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/openssl_types.hpp +34 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/password_callback.hpp +66 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/read_op.hpp +72 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/shutdown_op.hpp +69 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/stream_core.hpp +169 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/verify_callback.hpp +62 -0
- data/ext/third_party/asio/asio/include/asio/ssl/detail/write_op.hpp +76 -0
- data/ext/third_party/asio/asio/include/asio/ssl/error.hpp +125 -0
- data/ext/third_party/asio/asio/include/asio/ssl/host_name_verification.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/context.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/context.ipp +1238 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/error.ipp +102 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/host_name_verification.ipp +73 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/rfc2818_verification.ipp +164 -0
- data/ext/third_party/asio/asio/include/asio/ssl/impl/src.hpp +29 -0
- data/ext/third_party/asio/asio/include/asio/ssl/rfc2818_verification.hpp +98 -0
- data/ext/third_party/asio/asio/include/asio/ssl/stream.hpp +900 -0
- data/ext/third_party/asio/asio/include/asio/ssl/stream_base.hpp +52 -0
- data/ext/third_party/asio/asio/include/asio/ssl/verify_context.hpp +67 -0
- data/ext/third_party/asio/asio/include/asio/ssl/verify_mode.hpp +63 -0
- data/ext/third_party/asio/asio/include/asio/static_thread_pool.hpp +31 -0
- data/ext/third_party/asio/asio/include/asio/steady_timer.hpp +42 -0
- data/ext/third_party/asio/asio/include/asio/strand.hpp +537 -0
- data/ext/third_party/asio/asio/include/asio/streambuf.hpp +33 -0
- data/ext/third_party/asio/asio/include/asio/system_context.hpp +90 -0
- data/ext/third_party/asio/asio/include/asio/system_error.hpp +131 -0
- data/ext/third_party/asio/asio/include/asio/system_executor.hpp +662 -0
- data/ext/third_party/asio/asio/include/asio/system_timer.hpp +42 -0
- data/ext/third_party/asio/asio/include/asio/this_coro.hpp +45 -0
- data/ext/third_party/asio/asio/include/asio/thread.hpp +92 -0
- data/ext/third_party/asio/asio/include/asio/thread_pool.hpp +1111 -0
- data/ext/third_party/asio/asio/include/asio/time_traits.hpp +86 -0
- data/ext/third_party/asio/asio/include/asio/traits/bulk_execute_free.hpp +114 -0
- data/ext/third_party/asio/asio/include/asio/traits/bulk_execute_member.hpp +114 -0
- data/ext/third_party/asio/asio/include/asio/traits/connect_free.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/traits/connect_member.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/traits/equality_comparable.hpp +100 -0
- data/ext/third_party/asio/asio/include/asio/traits/execute_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/execute_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/prefer_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/prefer_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/query_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/query_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/query_static_constexpr_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/require_concept_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/require_concept_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/require_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/require_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/schedule_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/schedule_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_done_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_done_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_error_free.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_error_member.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_value_free.hpp +234 -0
- data/ext/third_party/asio/asio/include/asio/traits/set_value_member.hpp +234 -0
- data/ext/third_party/asio/asio/include/asio/traits/start_free.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/start_member.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/static_query.hpp +108 -0
- data/ext/third_party/asio/asio/include/asio/traits/static_require.hpp +123 -0
- data/ext/third_party/asio/asio/include/asio/traits/static_require_concept.hpp +123 -0
- data/ext/third_party/asio/asio/include/asio/traits/submit_free.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/traits/submit_member.hpp +112 -0
- data/ext/third_party/asio/asio/include/asio/ts/buffer.hpp +24 -0
- data/ext/third_party/asio/asio/include/asio/ts/executor.hpp +35 -0
- data/ext/third_party/asio/asio/include/asio/ts/internet.hpp +40 -0
- data/ext/third_party/asio/asio/include/asio/ts/io_context.hpp +20 -0
- data/ext/third_party/asio/asio/include/asio/ts/net.hpp +26 -0
- data/ext/third_party/asio/asio/include/asio/ts/netfwd.hpp +262 -0
- data/ext/third_party/asio/asio/include/asio/ts/socket.hpp +27 -0
- data/ext/third_party/asio/asio/include/asio/ts/timer.hpp +26 -0
- data/ext/third_party/asio/asio/include/asio/unyield.hpp +21 -0
- data/ext/third_party/asio/asio/include/asio/use_awaitable.hpp +169 -0
- data/ext/third_party/asio/asio/include/asio/use_future.hpp +160 -0
- data/ext/third_party/asio/asio/include/asio/uses_executor.hpp +71 -0
- data/ext/third_party/asio/asio/include/asio/version.hpp +23 -0
- data/ext/third_party/asio/asio/include/asio/wait_traits.hpp +56 -0
- data/ext/third_party/asio/asio/include/asio/windows/basic_object_handle.hpp +435 -0
- data/ext/third_party/asio/asio/include/asio/windows/basic_overlapped_handle.hpp +361 -0
- data/ext/third_party/asio/asio/include/asio/windows/basic_random_access_handle.hpp +490 -0
- data/ext/third_party/asio/asio/include/asio/windows/basic_stream_handle.hpp +474 -0
- data/ext/third_party/asio/asio/include/asio/windows/object_handle.hpp +38 -0
- data/ext/third_party/asio/asio/include/asio/windows/overlapped_handle.hpp +39 -0
- data/ext/third_party/asio/asio/include/asio/windows/overlapped_ptr.hpp +145 -0
- data/ext/third_party/asio/asio/include/asio/windows/random_access_handle.hpp +37 -0
- data/ext/third_party/asio/asio/include/asio/windows/stream_handle.hpp +37 -0
- data/ext/third_party/asio/asio/include/asio/write.hpp +1246 -0
- data/ext/third_party/asio/asio/include/asio/write_at.hpp +702 -0
- data/ext/third_party/asio/asio/include/asio/yield.hpp +23 -0
- data/ext/third_party/gsl/CMakeLists.txt +127 -0
- data/ext/third_party/gsl/LICENSE +21 -0
- data/ext/third_party/gsl/ThirdPartyNotices.txt +41 -0
- data/ext/third_party/gsl/include/gsl/gsl +29 -0
- data/ext/third_party/gsl/include/gsl/gsl_algorithm +61 -0
- data/ext/third_party/gsl/include/gsl/gsl_assert +133 -0
- data/ext/third_party/gsl/include/gsl/gsl_byte +209 -0
- data/ext/third_party/gsl/include/gsl/gsl_narrow +52 -0
- data/ext/third_party/gsl/include/gsl/gsl_util +129 -0
- data/ext/third_party/gsl/include/gsl/multi_span +2263 -0
- data/ext/third_party/gsl/include/gsl/pointers +287 -0
- data/ext/third_party/gsl/include/gsl/span +816 -0
- data/ext/third_party/gsl/include/gsl/span_ext +198 -0
- data/ext/third_party/gsl/include/gsl/string_span +706 -0
- data/ext/third_party/http_parser/LICENSE-MIT +19 -0
- data/ext/third_party/http_parser/http_parser.c +2575 -0
- data/ext/third_party/http_parser/http_parser.h +449 -0
- data/ext/third_party/json/CMakeLists.txt +44 -0
- data/ext/third_party/json/LICENSE +21 -0
- data/ext/third_party/json/LICENSE.double-conversion +32 -0
- data/ext/third_party/json/LICENSE.itoa +19 -0
- data/ext/third_party/json/LICENSE.ryu +201 -0
- data/ext/third_party/json/include/tao/json.hpp +45 -0
- data/ext/third_party/json/include/tao/json/basic_value.hpp +942 -0
- data/ext/third_party/json/include/tao/json/binary.hpp +103 -0
- data/ext/third_party/json/include/tao/json/binary_view.hpp +31 -0
- data/ext/third_party/json/include/tao/json/binding.hpp +71 -0
- data/ext/third_party/json/include/tao/json/binding/constant.hpp +232 -0
- data/ext/third_party/json/include/tao/json/binding/element.hpp +182 -0
- data/ext/third_party/json/include/tao/json/binding/factory.hpp +251 -0
- data/ext/third_party/json/include/tao/json/binding/for_nothing_value.hpp +17 -0
- data/ext/third_party/json/include/tao/json/binding/for_unknown_key.hpp +17 -0
- data/ext/third_party/json/include/tao/json/binding/inherit.hpp +14 -0
- data/ext/third_party/json/include/tao/json/binding/internal/array.hpp +104 -0
- data/ext/third_party/json/include/tao/json/binding/internal/inherit.hpp +45 -0
- data/ext/third_party/json/include/tao/json/binding/internal/object.hpp +268 -0
- data/ext/third_party/json/include/tao/json/binding/internal/type_key.hpp +54 -0
- data/ext/third_party/json/include/tao/json/binding/member.hpp +32 -0
- data/ext/third_party/json/include/tao/json/binding/member_kind.hpp +17 -0
- data/ext/third_party/json/include/tao/json/binding/versions.hpp +129 -0
- data/ext/third_party/json/include/tao/json/cbor.hpp +19 -0
- data/ext/third_party/json/include/tao/json/cbor/consume_file.hpp +34 -0
- data/ext/third_party/json/include/tao/json/cbor/consume_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/cbor/events/from_binary.hpp +43 -0
- data/ext/third_party/json/include/tao/json/cbor/events/from_file.hpp +27 -0
- data/ext/third_party/json/include/tao/json/cbor/events/from_input.hpp +43 -0
- data/ext/third_party/json/include/tao/json/cbor/events/from_string.hpp +37 -0
- data/ext/third_party/json/include/tao/json/cbor/events/to_stream.hpp +161 -0
- data/ext/third_party/json/include/tao/json/cbor/events/to_string.hpp +31 -0
- data/ext/third_party/json/include/tao/json/cbor/from_binary.hpp +32 -0
- data/ext/third_party/json/include/tao/json/cbor/from_file.hpp +33 -0
- data/ext/third_party/json/include/tao/json/cbor/from_input.hpp +33 -0
- data/ext/third_party/json/include/tao/json/cbor/from_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/cbor/internal/grammar.hpp +418 -0
- data/ext/third_party/json/include/tao/json/cbor/internal/major.hpp +28 -0
- data/ext/third_party/json/include/tao/json/cbor/parts_parser.hpp +392 -0
- data/ext/third_party/json/include/tao/json/cbor/to_stream.hpp +27 -0
- data/ext/third_party/json/include/tao/json/cbor/to_string.hpp +28 -0
- data/ext/third_party/json/include/tao/json/consume.hpp +43 -0
- data/ext/third_party/json/include/tao/json/consume_file.hpp +33 -0
- data/ext/third_party/json/include/tao/json/consume_string.hpp +31 -0
- data/ext/third_party/json/include/tao/json/contrib/array_traits.hpp +43 -0
- data/ext/third_party/json/include/tao/json/contrib/deque_traits.hpp +41 -0
- data/ext/third_party/json/include/tao/json/contrib/diff.hpp +106 -0
- data/ext/third_party/json/include/tao/json/contrib/get.hpp +152 -0
- data/ext/third_party/json/include/tao/json/contrib/internal/array_traits.hpp +92 -0
- data/ext/third_party/json/include/tao/json/contrib/internal/indirect_traits.hpp +76 -0
- data/ext/third_party/json/include/tao/json/contrib/internal/object_traits.hpp +105 -0
- data/ext/third_party/json/include/tao/json/contrib/internal/type_traits.hpp +36 -0
- data/ext/third_party/json/include/tao/json/contrib/list_traits.hpp +41 -0
- data/ext/third_party/json/include/tao/json/contrib/map_traits.hpp +43 -0
- data/ext/third_party/json/include/tao/json/contrib/multimap_traits.hpp +43 -0
- data/ext/third_party/json/include/tao/json/contrib/multiset_traits.hpp +41 -0
- data/ext/third_party/json/include/tao/json/contrib/pair_traits.hpp +21 -0
- data/ext/third_party/json/include/tao/json/contrib/patch.hpp +105 -0
- data/ext/third_party/json/include/tao/json/contrib/pointer_traits.hpp +59 -0
- data/ext/third_party/json/include/tao/json/contrib/position.hpp +166 -0
- data/ext/third_party/json/include/tao/json/contrib/reference.hpp +113 -0
- data/ext/third_party/json/include/tao/json/contrib/schema.hpp +1874 -0
- data/ext/third_party/json/include/tao/json/contrib/set_traits.hpp +41 -0
- data/ext/third_party/json/include/tao/json/contrib/shared_ptr_traits.hpp +98 -0
- data/ext/third_party/json/include/tao/json/contrib/traits.hpp +121 -0
- data/ext/third_party/json/include/tao/json/contrib/tuple_traits.hpp +51 -0
- data/ext/third_party/json/include/tao/json/contrib/unique_ptr_traits.hpp +97 -0
- data/ext/third_party/json/include/tao/json/contrib/unordered_map_traits.hpp +43 -0
- data/ext/third_party/json/include/tao/json/contrib/unordered_set_traits.hpp +41 -0
- data/ext/third_party/json/include/tao/json/contrib/vector_bool_traits.hpp +45 -0
- data/ext/third_party/json/include/tao/json/contrib/vector_traits.hpp +51 -0
- data/ext/third_party/json/include/tao/json/events.hpp +47 -0
- data/ext/third_party/json/include/tao/json/events/apply.hpp +20 -0
- data/ext/third_party/json/include/tao/json/events/binary_to_base64.hpp +26 -0
- data/ext/third_party/json/include/tao/json/events/binary_to_base64url.hpp +28 -0
- data/ext/third_party/json/include/tao/json/events/binary_to_exception.hpp +27 -0
- data/ext/third_party/json/include/tao/json/events/binary_to_hex.hpp +26 -0
- data/ext/third_party/json/include/tao/json/events/compare.hpp +255 -0
- data/ext/third_party/json/include/tao/json/events/debug.hpp +145 -0
- data/ext/third_party/json/include/tao/json/events/discard.hpp +43 -0
- data/ext/third_party/json/include/tao/json/events/from_file.hpp +28 -0
- data/ext/third_party/json/include/tao/json/events/from_input.hpp +45 -0
- data/ext/third_party/json/include/tao/json/events/from_stream.hpp +33 -0
- data/ext/third_party/json/include/tao/json/events/from_string.hpp +38 -0
- data/ext/third_party/json/include/tao/json/events/from_value.hpp +202 -0
- data/ext/third_party/json/include/tao/json/events/hash.hpp +174 -0
- data/ext/third_party/json/include/tao/json/events/invalid_string_to_binary.hpp +50 -0
- data/ext/third_party/json/include/tao/json/events/invalid_string_to_exception.hpp +49 -0
- data/ext/third_party/json/include/tao/json/events/invalid_string_to_hex.hpp +48 -0
- data/ext/third_party/json/include/tao/json/events/key_camel_case_to_snake_case.hpp +62 -0
- data/ext/third_party/json/include/tao/json/events/key_snake_case_to_camel_case.hpp +57 -0
- data/ext/third_party/json/include/tao/json/events/limit_nesting_depth.hpp +82 -0
- data/ext/third_party/json/include/tao/json/events/limit_value_count.hpp +46 -0
- data/ext/third_party/json/include/tao/json/events/non_finite_to_exception.hpp +31 -0
- data/ext/third_party/json/include/tao/json/events/non_finite_to_null.hpp +32 -0
- data/ext/third_party/json/include/tao/json/events/non_finite_to_string.hpp +40 -0
- data/ext/third_party/json/include/tao/json/events/prefer_signed.hpp +32 -0
- data/ext/third_party/json/include/tao/json/events/prefer_unsigned.hpp +32 -0
- data/ext/third_party/json/include/tao/json/events/produce.hpp +22 -0
- data/ext/third_party/json/include/tao/json/events/ref.hpp +111 -0
- data/ext/third_party/json/include/tao/json/events/statistics.hpp +112 -0
- data/ext/third_party/json/include/tao/json/events/tee.hpp +386 -0
- data/ext/third_party/json/include/tao/json/events/to_pretty_stream.hpp +172 -0
- data/ext/third_party/json/include/tao/json/events/to_stream.hpp +142 -0
- data/ext/third_party/json/include/tao/json/events/to_string.hpp +33 -0
- data/ext/third_party/json/include/tao/json/events/to_value.hpp +137 -0
- data/ext/third_party/json/include/tao/json/events/transformer.hpp +70 -0
- data/ext/third_party/json/include/tao/json/events/validate_event_order.hpp +411 -0
- data/ext/third_party/json/include/tao/json/events/validate_keys.hpp +51 -0
- data/ext/third_party/json/include/tao/json/events/virtual_base.hpp +192 -0
- data/ext/third_party/json/include/tao/json/events/virtual_ref.hpp +176 -0
- data/ext/third_party/json/include/tao/json/external/double.hpp +1313 -0
- data/ext/third_party/json/include/tao/json/external/itoa.hpp +149 -0
- data/ext/third_party/json/include/tao/json/external/pegtl.hpp +44 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/apply_mode.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/argv_input.hpp +49 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/ascii.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/buffer_input.hpp +212 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_action.hpp +38 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_action_and_state.hpp +53 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_action_and_states.hpp +62 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_control.hpp +36 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_state.hpp +50 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/change_states.hpp +61 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/config.hpp +11 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/abnf.hpp +35 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/alphabet.hpp +67 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/analyze.hpp +176 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/analyze_traits.hpp +275 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/control_action.hpp +77 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/coverage.hpp +151 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/forward.hpp +16 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/http.hpp +272 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/internal.hpp +66 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf16.hpp +196 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf32.hpp +196 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/icu/utf8.hpp +103 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/if_then.hpp +56 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/integer.hpp +431 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/endian.hpp +62 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/endian_gcc.hpp +206 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/endian_win.hpp +106 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_mask_uint.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_mask_uint8.hpp +33 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_uint.hpp +45 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_uint8.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_utf16.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/peek_utf32.hpp +43 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/read_uint.hpp +77 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/internal/set_stack_guard.hpp +52 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/json.hpp +88 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/json_pointer.hpp +33 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/parse_tree.hpp +440 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/parse_tree_to_dot.hpp +105 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/print.hpp +75 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/print_coverage.hpp +53 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/raw_string.hpp +234 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/remove_first_state.hpp +69 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/remove_last_states.hpp +117 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/rep_one_min_max.hpp +94 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/rep_string.hpp +43 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/shuffle_states.hpp +193 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/state_control.hpp +118 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/to_string.hpp +38 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/trace.hpp +227 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uint16.hpp +62 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uint32.hpp +62 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uint64.hpp +63 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uint8.hpp +36 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/unescape.hpp +199 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/uri.hpp +106 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/utf16.hpp +49 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/contrib/utf32.hpp +49 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/cstream_input.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/demangle.hpp +138 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/disable_action.hpp +35 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/discard_input.hpp +37 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/discard_input_on_failure.hpp +39 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/discard_input_on_success.hpp +39 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/enable_action.hpp +35 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/eol.hpp +37 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/eol_pair.hpp +18 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/file_input.hpp +44 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/action.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/action_input.hpp +106 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/any.hpp +58 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply.hpp +53 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply0.hpp +51 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply0_single.hpp +34 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/apply_single.hpp +34 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/at.hpp +55 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/bof.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/bol.hpp +31 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/bump.hpp +45 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/bump_help.hpp +29 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/bytes.hpp +43 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/control.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/cr_crlf_eol.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/cr_eol.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/crlf_eol.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/cstream_reader.hpp +49 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/cstring_reader.hpp +40 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/dependent_false.hpp +16 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/disable.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/discard.hpp +34 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/enable.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/enable_control.hpp +25 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/eof.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/eol.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/eolf.hpp +33 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/failure.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_mapper_posix.hpp +134 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_mapper_win32.hpp +213 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/file_reader.hpp +113 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_apply.hpp +21 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_apply0.hpp +21 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_match.hpp +40 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/has_unwind.hpp +21 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/identifier.hpp +22 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_apply.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_must.hpp +47 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_must_else.hpp +21 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/if_then_else.hpp +51 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/input_pair.hpp +29 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/istream_reader.hpp +39 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/istring.hpp +72 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/iterator.hpp +49 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/lf_crlf_eol.hpp +37 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/lf_eol.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/list.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/list_must.hpp +20 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/list_tail.hpp +22 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/list_tail_pad.hpp +22 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/marker.hpp +80 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/minus.hpp +21 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/missing_apply.hpp +28 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/missing_apply0.hpp +26 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/must.hpp +64 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/not_at.hpp +55 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/one.hpp +55 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/opt.hpp +57 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/pad.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/pad_opt.hpp +20 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/path_to_string.hpp +26 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/peek_char.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/peek_utf8.hpp +89 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/pegtl_string.hpp +90 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/plus.hpp +60 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/raise.hpp +44 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/range.hpp +56 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/ranges.hpp +103 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rematch.hpp +72 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep.hpp +67 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep_min.hpp +20 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep_min_max.hpp +81 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rep_opt.hpp +61 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/require.hpp +42 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/result_on_found.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/rules.hpp +61 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/seq.hpp +58 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/sor.hpp +67 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/star.hpp +52 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/star_must.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/state.hpp +59 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/string.hpp +58 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/success.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/try_catch_type.hpp +64 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/internal/until.hpp +88 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/istream_input.hpp +32 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/match.hpp +169 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/memory_input.hpp +365 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/mmap_input.hpp +79 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/must_if.hpp +64 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/normal.hpp +87 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/nothing.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/parse.hpp +51 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/parse_error.hpp +114 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/position.hpp +83 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/read_input.hpp +54 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/require_apply.hpp +16 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/require_apply0.hpp +16 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/rewind_mode.hpp +20 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/rules.hpp +68 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/string_input.hpp +64 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/tracking_mode.hpp +19 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/type_list.hpp +46 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/utf8.hpp +28 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/version.hpp +13 -0
- data/ext/third_party/json/include/tao/json/external/pegtl/visit.hpp +66 -0
- data/ext/third_party/json/include/tao/json/external/ryu.hpp +1216 -0
- data/ext/third_party/json/include/tao/json/forward.hpp +44 -0
- data/ext/third_party/json/include/tao/json/from_file.hpp +32 -0
- data/ext/third_party/json/include/tao/json/from_input.hpp +32 -0
- data/ext/third_party/json/include/tao/json/from_stream.hpp +45 -0
- data/ext/third_party/json/include/tao/json/from_string.hpp +41 -0
- data/ext/third_party/json/include/tao/json/internal/action.hpp +268 -0
- data/ext/third_party/json/include/tao/json/internal/base64.hpp +55 -0
- data/ext/third_party/json/include/tao/json/internal/base64url.hpp +53 -0
- data/ext/third_party/json/include/tao/json/internal/dependent_false.hpp +14 -0
- data/ext/third_party/json/include/tao/json/internal/endian.hpp +60 -0
- data/ext/third_party/json/include/tao/json/internal/endian_gcc.hpp +198 -0
- data/ext/third_party/json/include/tao/json/internal/endian_win.hpp +103 -0
- data/ext/third_party/json/include/tao/json/internal/errors.hpp +85 -0
- data/ext/third_party/json/include/tao/json/internal/escape.hpp +77 -0
- data/ext/third_party/json/include/tao/json/internal/format.hpp +57 -0
- data/ext/third_party/json/include/tao/json/internal/grammar.hpp +229 -0
- data/ext/third_party/json/include/tao/json/internal/hexdump.hpp +31 -0
- data/ext/third_party/json/include/tao/json/internal/identity.hpp +22 -0
- data/ext/third_party/json/include/tao/json/internal/number_state.hpp +80 -0
- data/ext/third_party/json/include/tao/json/internal/number_traits.hpp +267 -0
- data/ext/third_party/json/include/tao/json/internal/pair.hpp +42 -0
- data/ext/third_party/json/include/tao/json/internal/parse_util.hpp +112 -0
- data/ext/third_party/json/include/tao/json/internal/sha256.hpp +218 -0
- data/ext/third_party/json/include/tao/json/internal/single.hpp +40 -0
- data/ext/third_party/json/include/tao/json/internal/string_t.hpp +35 -0
- data/ext/third_party/json/include/tao/json/internal/type_traits.hpp +96 -0
- data/ext/third_party/json/include/tao/json/internal/unescape_action.hpp +24 -0
- data/ext/third_party/json/include/tao/json/internal/uri_fragment.hpp +182 -0
- data/ext/third_party/json/include/tao/json/jaxn.hpp +19 -0
- data/ext/third_party/json/include/tao/json/jaxn/consume_file.hpp +34 -0
- data/ext/third_party/json/include/tao/json/jaxn/consume_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/from_file.hpp +28 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/from_input.hpp +45 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/from_stream.hpp +33 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/from_string.hpp +39 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/to_pretty_stream.hpp +69 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/to_stream.hpp +67 -0
- data/ext/third_party/json/include/tao/json/jaxn/events/to_string.hpp +33 -0
- data/ext/third_party/json/include/tao/json/jaxn/from_file.hpp +33 -0
- data/ext/third_party/json/include/tao/json/jaxn/from_input.hpp +33 -0
- data/ext/third_party/json/include/tao/json/jaxn/from_stream.hpp +48 -0
- data/ext/third_party/json/include/tao/json/jaxn/from_string.hpp +42 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/action.hpp +355 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/bunescape_action.hpp +114 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/errors.hpp +108 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/grammar.hpp +375 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/integer.hpp +255 -0
- data/ext/third_party/json/include/tao/json/jaxn/internal/unescape_action.hpp +28 -0
- data/ext/third_party/json/include/tao/json/jaxn/is_identifier.hpp +27 -0
- data/ext/third_party/json/include/tao/json/jaxn/parts_parser.hpp +261 -0
- data/ext/third_party/json/include/tao/json/jaxn/to_stream.hpp +36 -0
- data/ext/third_party/json/include/tao/json/jaxn/to_string.hpp +33 -0
- data/ext/third_party/json/include/tao/json/message_extension.hpp +49 -0
- data/ext/third_party/json/include/tao/json/msgpack.hpp +19 -0
- data/ext/third_party/json/include/tao/json/msgpack/consume_file.hpp +34 -0
- data/ext/third_party/json/include/tao/json/msgpack/consume_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/from_binary.hpp +43 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/from_file.hpp +27 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/from_input.hpp +43 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/from_string.hpp +37 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/to_stream.hpp +214 -0
- data/ext/third_party/json/include/tao/json/msgpack/events/to_string.hpp +31 -0
- data/ext/third_party/json/include/tao/json/msgpack/from_binary.hpp +32 -0
- data/ext/third_party/json/include/tao/json/msgpack/from_file.hpp +33 -0
- data/ext/third_party/json/include/tao/json/msgpack/from_input.hpp +33 -0
- data/ext/third_party/json/include/tao/json/msgpack/from_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/msgpack/internal/format.hpp +57 -0
- data/ext/third_party/json/include/tao/json/msgpack/internal/grammar.hpp +250 -0
- data/ext/third_party/json/include/tao/json/msgpack/parts_parser.hpp +311 -0
- data/ext/third_party/json/include/tao/json/msgpack/to_stream.hpp +27 -0
- data/ext/third_party/json/include/tao/json/msgpack/to_string.hpp +28 -0
- data/ext/third_party/json/include/tao/json/operators.hpp +490 -0
- data/ext/third_party/json/include/tao/json/parts_parser.hpp +302 -0
- data/ext/third_party/json/include/tao/json/pointer.hpp +432 -0
- data/ext/third_party/json/include/tao/json/produce.hpp +61 -0
- data/ext/third_party/json/include/tao/json/self_contained.hpp +131 -0
- data/ext/third_party/json/include/tao/json/span.hpp +496 -0
- data/ext/third_party/json/include/tao/json/stream.hpp +38 -0
- data/ext/third_party/json/include/tao/json/to_stream.hpp +42 -0
- data/ext/third_party/json/include/tao/json/to_string.hpp +23 -0
- data/ext/third_party/json/include/tao/json/traits.hpp +971 -0
- data/ext/third_party/json/include/tao/json/type.hpp +112 -0
- data/ext/third_party/json/include/tao/json/ubjson.hpp +19 -0
- data/ext/third_party/json/include/tao/json/ubjson/consume_file.hpp +34 -0
- data/ext/third_party/json/include/tao/json/ubjson/consume_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/from_binary.hpp +43 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/from_file.hpp +27 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/from_input.hpp +43 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/from_string.hpp +37 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/to_stream.hpp +174 -0
- data/ext/third_party/json/include/tao/json/ubjson/events/to_string.hpp +31 -0
- data/ext/third_party/json/include/tao/json/ubjson/from_binary.hpp +32 -0
- data/ext/third_party/json/include/tao/json/ubjson/from_file.hpp +33 -0
- data/ext/third_party/json/include/tao/json/ubjson/from_input.hpp +33 -0
- data/ext/third_party/json/include/tao/json/ubjson/from_string.hpp +32 -0
- data/ext/third_party/json/include/tao/json/ubjson/internal/grammar.hpp +415 -0
- data/ext/third_party/json/include/tao/json/ubjson/internal/marker.hpp +46 -0
- data/ext/third_party/json/include/tao/json/ubjson/parts_parser.hpp +393 -0
- data/ext/third_party/json/include/tao/json/ubjson/to_stream.hpp +28 -0
- data/ext/third_party/json/include/tao/json/ubjson/to_string.hpp +29 -0
- data/ext/third_party/json/include/tao/json/utf8.hpp +57 -0
- data/ext/third_party/json/include/tao/json/value.hpp +12 -0
- data/ext/third_party/snappy/CMakeLists.txt +345 -0
- data/ext/third_party/snappy/COPYING +54 -0
- data/ext/third_party/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/ext/third_party/snappy/cmake/config.h.in +59 -0
- data/ext/third_party/snappy/snappy-c.cc +90 -0
- data/ext/third_party/snappy/snappy-c.h +138 -0
- data/ext/third_party/snappy/snappy-internal.h +315 -0
- data/ext/third_party/snappy/snappy-sinksource.cc +121 -0
- data/ext/third_party/snappy/snappy-sinksource.h +182 -0
- data/ext/third_party/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/third_party/snappy/snappy-stubs-internal.h +493 -0
- data/ext/third_party/snappy/snappy-stubs-public.h.in +63 -0
- data/ext/third_party/snappy/snappy.cc +1774 -0
- data/ext/third_party/snappy/snappy.h +209 -0
- data/ext/third_party/spdlog/CMakeLists.txt +291 -0
- data/ext/third_party/spdlog/LICENSE +26 -0
- data/ext/third_party/spdlog/cmake/ide.cmake +18 -0
- data/ext/third_party/spdlog/cmake/pch.h.in +258 -0
- data/ext/third_party/spdlog/cmake/spdlog.pc.in +13 -0
- data/ext/third_party/spdlog/cmake/spdlogCPack.cmake +46 -0
- data/ext/third_party/spdlog/cmake/spdlogConfig.cmake.in +15 -0
- data/ext/third_party/spdlog/cmake/utils.cmake +61 -0
- data/ext/third_party/spdlog/cmake/version.rc.in +42 -0
- data/ext/third_party/spdlog/include/spdlog/async.h +93 -0
- data/ext/third_party/spdlog/include/spdlog/async_logger-inl.h +92 -0
- data/ext/third_party/spdlog/include/spdlog/async_logger.h +68 -0
- data/ext/third_party/spdlog/include/spdlog/cfg/argv.h +44 -0
- data/ext/third_party/spdlog/include/spdlog/cfg/env.h +38 -0
- data/ext/third_party/spdlog/include/spdlog/cfg/helpers-inl.h +119 -0
- data/ext/third_party/spdlog/include/spdlog/cfg/helpers.h +29 -0
- data/ext/third_party/spdlog/include/spdlog/common-inl.h +76 -0
- data/ext/third_party/spdlog/include/spdlog/common.h +245 -0
- data/ext/third_party/spdlog/include/spdlog/details/backtracer-inl.h +69 -0
- data/ext/third_party/spdlog/include/spdlog/details/backtracer.h +45 -0
- data/ext/third_party/spdlog/include/spdlog/details/circular_q.h +141 -0
- data/ext/third_party/spdlog/include/spdlog/details/console_globals.h +32 -0
- data/ext/third_party/spdlog/include/spdlog/details/file_helper-inl.h +132 -0
- data/ext/third_party/spdlog/include/spdlog/details/file_helper.h +59 -0
- data/ext/third_party/spdlog/include/spdlog/details/fmt_helper.h +116 -0
- data/ext/third_party/spdlog/include/spdlog/details/log_msg-inl.h +37 -0
- data/ext/third_party/spdlog/include/spdlog/details/log_msg.h +36 -0
- data/ext/third_party/spdlog/include/spdlog/details/log_msg_buffer-inl.h +58 -0
- data/ext/third_party/spdlog/include/spdlog/details/log_msg_buffer.h +33 -0
- data/ext/third_party/spdlog/include/spdlog/details/mpmc_blocking_q.h +120 -0
- data/ext/third_party/spdlog/include/spdlog/details/null_mutex.h +49 -0
- data/ext/third_party/spdlog/include/spdlog/details/os-inl.h +554 -0
- data/ext/third_party/spdlog/include/spdlog/details/os.h +111 -0
- data/ext/third_party/spdlog/include/spdlog/details/periodic_worker-inl.h +49 -0
- data/ext/third_party/spdlog/include/spdlog/details/periodic_worker.h +40 -0
- data/ext/third_party/spdlog/include/spdlog/details/registry-inl.h +313 -0
- data/ext/third_party/spdlog/include/spdlog/details/registry.h +115 -0
- data/ext/third_party/spdlog/include/spdlog/details/synchronous_factory.h +24 -0
- data/ext/third_party/spdlog/include/spdlog/details/tcp_client-windows.h +175 -0
- data/ext/third_party/spdlog/include/spdlog/details/tcp_client.h +146 -0
- data/ext/third_party/spdlog/include/spdlog/details/thread_pool-inl.h +124 -0
- data/ext/third_party/spdlog/include/spdlog/details/thread_pool.h +120 -0
- data/ext/third_party/spdlog/include/spdlog/details/windows_include.h +11 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bin_to_hex.h +216 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/LICENSE.rst +27 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/chrono.h +1123 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/color.h +566 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/compile.h +665 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/core.h +1882 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/format-inl.h +1453 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/format.h +3729 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/locale.h +78 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/os.h +450 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/ostream.h +167 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/posix.h +2 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/printf.h +751 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/bundled/ranges.h +386 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/chrono.h +20 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/fmt.h +27 -0
- data/ext/third_party/spdlog/include/spdlog/fmt/ostr.h +20 -0
- data/ext/third_party/spdlog/include/spdlog/formatter.h +18 -0
- data/ext/third_party/spdlog/include/spdlog/fwd.h +14 -0
- data/ext/third_party/spdlog/include/spdlog/logger-inl.h +257 -0
- data/ext/third_party/spdlog/include/spdlog/logger.h +366 -0
- data/ext/third_party/spdlog/include/spdlog/pattern_formatter-inl.h +1373 -0
- data/ext/third_party/spdlog/include/spdlog/pattern_formatter.h +126 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/android_sink.h +119 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/ansicolor_sink-inl.h +143 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/ansicolor_sink.h +118 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/base_sink-inl.h +63 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/base_sink.h +52 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/basic_file_sink-inl.h +43 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/basic_file_sink.h +58 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/daily_file_sink.h +204 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/dist_sink.h +97 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/dup_filter_sink.h +90 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/msvc_sink.h +49 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/null_sink.h +44 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/ostream_sink.h +50 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/ringbuffer_sink.h +74 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/rotating_file_sink-inl.h +131 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/rotating_file_sink.h +78 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/sink-inl.h +25 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/sink.h +35 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/stdout_color_sinks-inl.h +38 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/stdout_color_sinks.h +45 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/stdout_sinks-inl.h +123 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/stdout_sinks.h +87 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/syslog_sink.h +109 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/systemd_sink.h +103 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/tcp_sink.h +81 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/win_eventlog_sink.h +266 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/wincolor_sink-inl.h +170 -0
- data/ext/third_party/spdlog/include/spdlog/sinks/wincolor_sink.h +94 -0
- data/ext/third_party/spdlog/include/spdlog/spdlog-inl.h +125 -0
- data/ext/third_party/spdlog/include/spdlog/spdlog.h +295 -0
- data/ext/third_party/spdlog/include/spdlog/stopwatch.h +61 -0
- data/ext/third_party/spdlog/include/spdlog/tweakme.h +116 -0
- data/ext/third_party/spdlog/include/spdlog/version.h +10 -0
- data/ext/third_party/spdlog/src/async.cpp +13 -0
- data/ext/third_party/spdlog/src/cfg.cpp +8 -0
- data/ext/third_party/spdlog/src/color_sinks.cpp +51 -0
- data/ext/third_party/spdlog/src/file_sinks.cpp +20 -0
- data/ext/third_party/spdlog/src/fmt.cpp +63 -0
- data/ext/third_party/spdlog/src/spdlog.cpp +26 -0
- data/ext/third_party/spdlog/src/stdout_sinks.cpp +29 -0
- data/lib/active_support/cache/couchbase_store.rb +362 -0
- data/lib/couchbase.rb +20 -0
- data/lib/couchbase/analytics_options.rb +107 -0
- data/lib/couchbase/authenticator.rb +65 -0
- data/lib/couchbase/binary_collection.rb +128 -0
- data/lib/couchbase/binary_collection_options.rb +24 -0
- data/lib/couchbase/bucket.rb +144 -0
- data/lib/couchbase/cluster.rb +430 -0
- data/lib/couchbase/collection.rb +562 -0
- data/lib/couchbase/collection_options.rb +324 -0
- data/lib/couchbase/configuration.rb +57 -0
- data/lib/couchbase/datastructures.rb +24 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +160 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +194 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +134 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +128 -0
- data/lib/couchbase/diagnostics.rb +181 -0
- data/lib/couchbase/errors.rb +345 -0
- data/lib/couchbase/json_transcoder.rb +32 -0
- data/lib/couchbase/libcouchbase.bundle +0 -0
- data/lib/couchbase/logger.rb +42 -0
- data/lib/couchbase/management.rb +27 -0
- data/lib/couchbase/management/analytics_index_manager.rb +433 -0
- data/lib/couchbase/management/bucket_manager.rb +292 -0
- data/lib/couchbase/management/collection_manager.rb +202 -0
- data/lib/couchbase/management/query_index_manager.rb +342 -0
- data/lib/couchbase/management/search_index_manager.rb +408 -0
- data/lib/couchbase/management/user_manager.rb +449 -0
- data/lib/couchbase/management/view_index_manager.rb +237 -0
- data/lib/couchbase/mutation_state.rb +63 -0
- data/lib/couchbase/options.rb +2104 -0
- data/lib/couchbase/query_options.rb +120 -0
- data/lib/couchbase/railtie.rb +45 -0
- data/lib/couchbase/scope.rb +127 -0
- data/lib/couchbase/search_options.rb +1487 -0
- data/lib/couchbase/subdoc.rb +290 -0
- data/lib/couchbase/utils.rb +21 -0
- data/lib/couchbase/utils/time.rb +52 -0
- data/lib/couchbase/version.rb +37 -0
- data/lib/couchbase/view_options.rb +65 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +27 -0
- metadata +1403 -0
@@ -0,0 +1,3962 @@
|
|
1
|
+
//
|
2
|
+
// detail/impl/socket_ops.ipp
|
3
|
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
4
|
+
//
|
5
|
+
// Copyright (c) 2003-2020 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_SOCKET_OPS_IPP
|
12
|
+
#define ASIO_DETAIL_SOCKET_OPS_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
|
+
#include <cctype>
|
21
|
+
#include <cstdio>
|
22
|
+
#include <cstdlib>
|
23
|
+
#include <cstring>
|
24
|
+
#include <cerrno>
|
25
|
+
#include <new>
|
26
|
+
#include "asio/detail/assert.hpp"
|
27
|
+
#include "asio/detail/socket_ops.hpp"
|
28
|
+
#include "asio/error.hpp"
|
29
|
+
|
30
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
31
|
+
# include <codecvt>
|
32
|
+
# include <locale>
|
33
|
+
# include <string>
|
34
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
35
|
+
|
36
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__) \
|
37
|
+
|| defined(__MACH__) && defined(__APPLE__)
|
38
|
+
# if defined(ASIO_HAS_PTHREADS)
|
39
|
+
# include <pthread.h>
|
40
|
+
# endif // defined(ASIO_HAS_PTHREADS)
|
41
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
42
|
+
// || defined(__MACH__) && defined(__APPLE__)
|
43
|
+
|
44
|
+
#include "asio/detail/push_options.hpp"
|
45
|
+
|
46
|
+
namespace asio {
|
47
|
+
namespace detail {
|
48
|
+
namespace socket_ops {
|
49
|
+
|
50
|
+
#if !defined(ASIO_WINDOWS_RUNTIME)
|
51
|
+
|
52
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
53
|
+
struct msghdr { int msg_namelen; };
|
54
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
55
|
+
|
56
|
+
#if defined(__hpux)
|
57
|
+
// HP-UX doesn't declare these functions extern "C", so they are declared again
|
58
|
+
// here to avoid linker errors about undefined symbols.
|
59
|
+
extern "C" char* if_indextoname(unsigned int, char*);
|
60
|
+
extern "C" unsigned int if_nametoindex(const char*);
|
61
|
+
#endif // defined(__hpux)
|
62
|
+
|
63
|
+
#endif // !defined(ASIO_WINDOWS_RUNTIME)
|
64
|
+
|
65
|
+
inline void clear_last_error()
|
66
|
+
{
|
67
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
68
|
+
WSASetLastError(0);
|
69
|
+
#else
|
70
|
+
errno = 0;
|
71
|
+
#endif
|
72
|
+
}
|
73
|
+
|
74
|
+
#if !defined(ASIO_WINDOWS_RUNTIME)
|
75
|
+
|
76
|
+
inline void get_last_error(
|
77
|
+
asio::error_code& ec, bool is_error_condition)
|
78
|
+
{
|
79
|
+
if (!is_error_condition)
|
80
|
+
{
|
81
|
+
ec.assign(0, ec.category());
|
82
|
+
}
|
83
|
+
else
|
84
|
+
{
|
85
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
86
|
+
ec = asio::error_code(WSAGetLastError(),
|
87
|
+
asio::error::get_system_category());
|
88
|
+
#else
|
89
|
+
ec = asio::error_code(errno,
|
90
|
+
asio::error::get_system_category());
|
91
|
+
#endif
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
template <typename SockLenType>
|
96
|
+
inline socket_type call_accept(SockLenType msghdr::*,
|
97
|
+
socket_type s, socket_addr_type* addr, std::size_t* addrlen)
|
98
|
+
{
|
99
|
+
SockLenType tmp_addrlen = addrlen ? (SockLenType)*addrlen : 0;
|
100
|
+
socket_type result = ::accept(s, addr, addrlen ? &tmp_addrlen : 0);
|
101
|
+
if (addrlen)
|
102
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
103
|
+
return result;
|
104
|
+
}
|
105
|
+
|
106
|
+
socket_type accept(socket_type s, socket_addr_type* addr,
|
107
|
+
std::size_t* addrlen, asio::error_code& ec)
|
108
|
+
{
|
109
|
+
if (s == invalid_socket)
|
110
|
+
{
|
111
|
+
ec = asio::error::bad_descriptor;
|
112
|
+
return invalid_socket;
|
113
|
+
}
|
114
|
+
|
115
|
+
socket_type new_s = call_accept(&msghdr::msg_namelen, s, addr, addrlen);
|
116
|
+
get_last_error(ec, new_s == invalid_socket);
|
117
|
+
if (new_s == invalid_socket)
|
118
|
+
return new_s;
|
119
|
+
|
120
|
+
#if defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
|
121
|
+
int optval = 1;
|
122
|
+
int result = ::setsockopt(new_s, SOL_SOCKET,
|
123
|
+
SO_NOSIGPIPE, &optval, sizeof(optval));
|
124
|
+
get_last_error(ec, result != 0);
|
125
|
+
if (result != 0)
|
126
|
+
{
|
127
|
+
::close(new_s);
|
128
|
+
return invalid_socket;
|
129
|
+
}
|
130
|
+
#endif
|
131
|
+
|
132
|
+
ec.assign(0, ec.category());
|
133
|
+
return new_s;
|
134
|
+
}
|
135
|
+
|
136
|
+
socket_type sync_accept(socket_type s, state_type state,
|
137
|
+
socket_addr_type* addr, std::size_t* addrlen, asio::error_code& ec)
|
138
|
+
{
|
139
|
+
// Accept a socket.
|
140
|
+
for (;;)
|
141
|
+
{
|
142
|
+
// Try to complete the operation without blocking.
|
143
|
+
socket_type new_socket = socket_ops::accept(s, addr, addrlen, ec);
|
144
|
+
|
145
|
+
// Check if operation succeeded.
|
146
|
+
if (new_socket != invalid_socket)
|
147
|
+
return new_socket;
|
148
|
+
|
149
|
+
// Operation failed.
|
150
|
+
if (ec == asio::error::would_block
|
151
|
+
|| ec == asio::error::try_again)
|
152
|
+
{
|
153
|
+
if (state & user_set_non_blocking)
|
154
|
+
return invalid_socket;
|
155
|
+
// Fall through to retry operation.
|
156
|
+
}
|
157
|
+
else if (ec == asio::error::connection_aborted)
|
158
|
+
{
|
159
|
+
if (state & enable_connection_aborted)
|
160
|
+
return invalid_socket;
|
161
|
+
// Fall through to retry operation.
|
162
|
+
}
|
163
|
+
#if defined(EPROTO)
|
164
|
+
else if (ec.value() == EPROTO)
|
165
|
+
{
|
166
|
+
if (state & enable_connection_aborted)
|
167
|
+
return invalid_socket;
|
168
|
+
// Fall through to retry operation.
|
169
|
+
}
|
170
|
+
#endif // defined(EPROTO)
|
171
|
+
else
|
172
|
+
return invalid_socket;
|
173
|
+
|
174
|
+
// Wait for socket to become ready.
|
175
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
176
|
+
return invalid_socket;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
#if defined(ASIO_HAS_IOCP)
|
181
|
+
|
182
|
+
void complete_iocp_accept(socket_type s,
|
183
|
+
void* output_buffer, DWORD address_length,
|
184
|
+
socket_addr_type* addr, std::size_t* addrlen,
|
185
|
+
socket_type new_socket, asio::error_code& ec)
|
186
|
+
{
|
187
|
+
// Map non-portable errors to their portable counterparts.
|
188
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
189
|
+
ec = asio::error::connection_aborted;
|
190
|
+
|
191
|
+
if (!ec)
|
192
|
+
{
|
193
|
+
// Get the address of the peer.
|
194
|
+
if (addr && addrlen)
|
195
|
+
{
|
196
|
+
LPSOCKADDR local_addr = 0;
|
197
|
+
int local_addr_length = 0;
|
198
|
+
LPSOCKADDR remote_addr = 0;
|
199
|
+
int remote_addr_length = 0;
|
200
|
+
GetAcceptExSockaddrs(output_buffer, 0, address_length,
|
201
|
+
address_length, &local_addr, &local_addr_length,
|
202
|
+
&remote_addr, &remote_addr_length);
|
203
|
+
if (static_cast<std::size_t>(remote_addr_length) > *addrlen)
|
204
|
+
{
|
205
|
+
ec = asio::error::invalid_argument;
|
206
|
+
}
|
207
|
+
else
|
208
|
+
{
|
209
|
+
using namespace std; // For memcpy.
|
210
|
+
memcpy(addr, remote_addr, remote_addr_length);
|
211
|
+
*addrlen = static_cast<std::size_t>(remote_addr_length);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
// Need to set the SO_UPDATE_ACCEPT_CONTEXT option so that getsockname
|
216
|
+
// and getpeername will work on the accepted socket.
|
217
|
+
SOCKET update_ctx_param = s;
|
218
|
+
socket_ops::state_type state = 0;
|
219
|
+
socket_ops::setsockopt(new_socket, state,
|
220
|
+
SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
|
221
|
+
&update_ctx_param, sizeof(SOCKET), ec);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
#else // defined(ASIO_HAS_IOCP)
|
226
|
+
|
227
|
+
bool non_blocking_accept(socket_type s,
|
228
|
+
state_type state, socket_addr_type* addr, std::size_t* addrlen,
|
229
|
+
asio::error_code& ec, socket_type& new_socket)
|
230
|
+
{
|
231
|
+
for (;;)
|
232
|
+
{
|
233
|
+
// Accept the waiting connection.
|
234
|
+
new_socket = socket_ops::accept(s, addr, addrlen, ec);
|
235
|
+
|
236
|
+
// Check if operation succeeded.
|
237
|
+
if (new_socket != invalid_socket)
|
238
|
+
return true;
|
239
|
+
|
240
|
+
// Retry operation if interrupted by signal.
|
241
|
+
if (ec == asio::error::interrupted)
|
242
|
+
continue;
|
243
|
+
|
244
|
+
// Operation failed.
|
245
|
+
if (ec == asio::error::would_block
|
246
|
+
|| ec == asio::error::try_again)
|
247
|
+
{
|
248
|
+
// Fall through to retry operation.
|
249
|
+
}
|
250
|
+
else if (ec == asio::error::connection_aborted)
|
251
|
+
{
|
252
|
+
if (state & enable_connection_aborted)
|
253
|
+
return true;
|
254
|
+
// Fall through to retry operation.
|
255
|
+
}
|
256
|
+
#if defined(EPROTO)
|
257
|
+
else if (ec.value() == EPROTO)
|
258
|
+
{
|
259
|
+
if (state & enable_connection_aborted)
|
260
|
+
return true;
|
261
|
+
// Fall through to retry operation.
|
262
|
+
}
|
263
|
+
#endif // defined(EPROTO)
|
264
|
+
else
|
265
|
+
return true;
|
266
|
+
|
267
|
+
return false;
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
#endif // defined(ASIO_HAS_IOCP)
|
272
|
+
|
273
|
+
template <typename SockLenType>
|
274
|
+
inline int call_bind(SockLenType msghdr::*,
|
275
|
+
socket_type s, const socket_addr_type* addr, std::size_t addrlen)
|
276
|
+
{
|
277
|
+
return ::bind(s, addr, (SockLenType)addrlen);
|
278
|
+
}
|
279
|
+
|
280
|
+
int bind(socket_type s, const socket_addr_type* addr,
|
281
|
+
std::size_t addrlen, asio::error_code& ec)
|
282
|
+
{
|
283
|
+
if (s == invalid_socket)
|
284
|
+
{
|
285
|
+
ec = asio::error::bad_descriptor;
|
286
|
+
return socket_error_retval;
|
287
|
+
}
|
288
|
+
|
289
|
+
int result = call_bind(&msghdr::msg_namelen, s, addr, addrlen);
|
290
|
+
get_last_error(ec, result != 0);
|
291
|
+
return result;
|
292
|
+
}
|
293
|
+
|
294
|
+
int close(socket_type s, state_type& state,
|
295
|
+
bool destruction, asio::error_code& ec)
|
296
|
+
{
|
297
|
+
int result = 0;
|
298
|
+
if (s != invalid_socket)
|
299
|
+
{
|
300
|
+
// We don't want the destructor to block, so set the socket to linger in
|
301
|
+
// the background. If the user doesn't like this behaviour then they need
|
302
|
+
// to explicitly close the socket.
|
303
|
+
if (destruction && (state & user_set_linger))
|
304
|
+
{
|
305
|
+
::linger opt;
|
306
|
+
opt.l_onoff = 0;
|
307
|
+
opt.l_linger = 0;
|
308
|
+
asio::error_code ignored_ec;
|
309
|
+
socket_ops::setsockopt(s, state, SOL_SOCKET,
|
310
|
+
SO_LINGER, &opt, sizeof(opt), ignored_ec);
|
311
|
+
}
|
312
|
+
|
313
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
314
|
+
result = ::closesocket(s);
|
315
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
316
|
+
result = ::close(s);
|
317
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
318
|
+
get_last_error(ec, result != 0);
|
319
|
+
|
320
|
+
if (result != 0
|
321
|
+
&& (ec == asio::error::would_block
|
322
|
+
|| ec == asio::error::try_again))
|
323
|
+
{
|
324
|
+
// According to UNIX Network Programming Vol. 1, it is possible for
|
325
|
+
// close() to fail with EWOULDBLOCK under certain circumstances. What
|
326
|
+
// isn't clear is the state of the descriptor after this error. The one
|
327
|
+
// current OS where this behaviour is seen, Windows, says that the socket
|
328
|
+
// remains open. Therefore we'll put the descriptor back into blocking
|
329
|
+
// mode and have another attempt at closing it.
|
330
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
331
|
+
ioctl_arg_type arg = 0;
|
332
|
+
::ioctlsocket(s, FIONBIO, &arg);
|
333
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
334
|
+
# if defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__)
|
335
|
+
int flags = ::fcntl(s, F_GETFL, 0);
|
336
|
+
if (flags >= 0)
|
337
|
+
::fcntl(s, F_SETFL, flags & ~O_NONBLOCK);
|
338
|
+
# else // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__)
|
339
|
+
ioctl_arg_type arg = 0;
|
340
|
+
::ioctl(s, FIONBIO, &arg);
|
341
|
+
# endif // defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__)
|
342
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
343
|
+
state &= ~non_blocking;
|
344
|
+
|
345
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
346
|
+
result = ::closesocket(s);
|
347
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
348
|
+
result = ::close(s);
|
349
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
350
|
+
get_last_error(ec, result != 0);
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
return result;
|
355
|
+
}
|
356
|
+
|
357
|
+
bool set_user_non_blocking(socket_type s,
|
358
|
+
state_type& state, bool value, asio::error_code& ec)
|
359
|
+
{
|
360
|
+
if (s == invalid_socket)
|
361
|
+
{
|
362
|
+
ec = asio::error::bad_descriptor;
|
363
|
+
return false;
|
364
|
+
}
|
365
|
+
|
366
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
367
|
+
ioctl_arg_type arg = (value ? 1 : 0);
|
368
|
+
int result = ::ioctlsocket(s, FIONBIO, &arg);
|
369
|
+
get_last_error(ec, result < 0);
|
370
|
+
#elif defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__)
|
371
|
+
int result = ::fcntl(s, F_GETFL, 0);
|
372
|
+
get_last_error(ec, result < 0);
|
373
|
+
if (result >= 0)
|
374
|
+
{
|
375
|
+
int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
|
376
|
+
result = ::fcntl(s, F_SETFL, flag);
|
377
|
+
get_last_error(ec, result < 0);
|
378
|
+
}
|
379
|
+
#else
|
380
|
+
ioctl_arg_type arg = (value ? 1 : 0);
|
381
|
+
int result = ::ioctl(s, FIONBIO, &arg);
|
382
|
+
get_last_error(ec, result < 0);
|
383
|
+
#endif
|
384
|
+
|
385
|
+
if (result >= 0)
|
386
|
+
{
|
387
|
+
if (value)
|
388
|
+
state |= user_set_non_blocking;
|
389
|
+
else
|
390
|
+
{
|
391
|
+
// Clearing the user-set non-blocking mode always overrides any
|
392
|
+
// internally-set non-blocking flag. Any subsequent asynchronous
|
393
|
+
// operations will need to re-enable non-blocking I/O.
|
394
|
+
state &= ~(user_set_non_blocking | internal_non_blocking);
|
395
|
+
}
|
396
|
+
return true;
|
397
|
+
}
|
398
|
+
|
399
|
+
return false;
|
400
|
+
}
|
401
|
+
|
402
|
+
bool set_internal_non_blocking(socket_type s,
|
403
|
+
state_type& state, bool value, asio::error_code& ec)
|
404
|
+
{
|
405
|
+
if (s == invalid_socket)
|
406
|
+
{
|
407
|
+
ec = asio::error::bad_descriptor;
|
408
|
+
return false;
|
409
|
+
}
|
410
|
+
|
411
|
+
if (!value && (state & user_set_non_blocking))
|
412
|
+
{
|
413
|
+
// It does not make sense to clear the internal non-blocking flag if the
|
414
|
+
// user still wants non-blocking behaviour. Return an error and let the
|
415
|
+
// caller figure out whether to update the user-set non-blocking flag.
|
416
|
+
ec = asio::error::invalid_argument;
|
417
|
+
return false;
|
418
|
+
}
|
419
|
+
|
420
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
421
|
+
ioctl_arg_type arg = (value ? 1 : 0);
|
422
|
+
int result = ::ioctlsocket(s, FIONBIO, &arg);
|
423
|
+
get_last_error(ec, result < 0);
|
424
|
+
#elif defined(__SYMBIAN32__) || defined(__EMSCRIPTEN__)
|
425
|
+
int result = ::fcntl(s, F_GETFL, 0);
|
426
|
+
get_last_error(ec, result < 0);
|
427
|
+
if (result >= 0)
|
428
|
+
{
|
429
|
+
int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
|
430
|
+
result = ::fcntl(s, F_SETFL, flag);
|
431
|
+
get_last_error(ec, result < 0);
|
432
|
+
}
|
433
|
+
#else
|
434
|
+
ioctl_arg_type arg = (value ? 1 : 0);
|
435
|
+
int result = ::ioctl(s, FIONBIO, &arg);
|
436
|
+
get_last_error(ec, result < 0);
|
437
|
+
#endif
|
438
|
+
|
439
|
+
if (result >= 0)
|
440
|
+
{
|
441
|
+
if (value)
|
442
|
+
state |= internal_non_blocking;
|
443
|
+
else
|
444
|
+
state &= ~internal_non_blocking;
|
445
|
+
return true;
|
446
|
+
}
|
447
|
+
|
448
|
+
return false;
|
449
|
+
}
|
450
|
+
|
451
|
+
int shutdown(socket_type s, int what, asio::error_code& ec)
|
452
|
+
{
|
453
|
+
if (s == invalid_socket)
|
454
|
+
{
|
455
|
+
ec = asio::error::bad_descriptor;
|
456
|
+
return socket_error_retval;
|
457
|
+
}
|
458
|
+
|
459
|
+
int result = ::shutdown(s, what);
|
460
|
+
get_last_error(ec, result != 0);
|
461
|
+
return result;
|
462
|
+
}
|
463
|
+
|
464
|
+
template <typename SockLenType>
|
465
|
+
inline int call_connect(SockLenType msghdr::*,
|
466
|
+
socket_type s, const socket_addr_type* addr, std::size_t addrlen)
|
467
|
+
{
|
468
|
+
return ::connect(s, addr, (SockLenType)addrlen);
|
469
|
+
}
|
470
|
+
|
471
|
+
int connect(socket_type s, const socket_addr_type* addr,
|
472
|
+
std::size_t addrlen, asio::error_code& ec)
|
473
|
+
{
|
474
|
+
if (s == invalid_socket)
|
475
|
+
{
|
476
|
+
ec = asio::error::bad_descriptor;
|
477
|
+
return socket_error_retval;
|
478
|
+
}
|
479
|
+
|
480
|
+
int result = call_connect(&msghdr::msg_namelen, s, addr, addrlen);
|
481
|
+
get_last_error(ec, result != 0);
|
482
|
+
#if defined(__linux__)
|
483
|
+
if (result != 0 && ec == asio::error::try_again)
|
484
|
+
ec = asio::error::no_buffer_space;
|
485
|
+
#endif // defined(__linux__)
|
486
|
+
return result;
|
487
|
+
}
|
488
|
+
|
489
|
+
void sync_connect(socket_type s, const socket_addr_type* addr,
|
490
|
+
std::size_t addrlen, asio::error_code& ec)
|
491
|
+
{
|
492
|
+
// Perform the connect operation.
|
493
|
+
socket_ops::connect(s, addr, addrlen, ec);
|
494
|
+
if (ec != asio::error::in_progress
|
495
|
+
&& ec != asio::error::would_block)
|
496
|
+
{
|
497
|
+
// The connect operation finished immediately.
|
498
|
+
return;
|
499
|
+
}
|
500
|
+
|
501
|
+
// Wait for socket to become ready.
|
502
|
+
if (socket_ops::poll_connect(s, -1, ec) < 0)
|
503
|
+
return;
|
504
|
+
|
505
|
+
// Get the error code from the connect operation.
|
506
|
+
int connect_error = 0;
|
507
|
+
size_t connect_error_len = sizeof(connect_error);
|
508
|
+
if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_ERROR,
|
509
|
+
&connect_error, &connect_error_len, ec) == socket_error_retval)
|
510
|
+
return;
|
511
|
+
|
512
|
+
// Return the result of the connect operation.
|
513
|
+
ec = asio::error_code(connect_error,
|
514
|
+
asio::error::get_system_category());
|
515
|
+
}
|
516
|
+
|
517
|
+
#if defined(ASIO_HAS_IOCP)
|
518
|
+
|
519
|
+
void complete_iocp_connect(socket_type s, asio::error_code& ec)
|
520
|
+
{
|
521
|
+
// Map non-portable errors to their portable counterparts.
|
522
|
+
switch (ec.value())
|
523
|
+
{
|
524
|
+
case ERROR_CONNECTION_REFUSED:
|
525
|
+
ec = asio::error::connection_refused;
|
526
|
+
break;
|
527
|
+
case ERROR_NETWORK_UNREACHABLE:
|
528
|
+
ec = asio::error::network_unreachable;
|
529
|
+
break;
|
530
|
+
case ERROR_HOST_UNREACHABLE:
|
531
|
+
ec = asio::error::host_unreachable;
|
532
|
+
break;
|
533
|
+
case ERROR_SEM_TIMEOUT:
|
534
|
+
ec = asio::error::timed_out;
|
535
|
+
break;
|
536
|
+
default:
|
537
|
+
break;
|
538
|
+
}
|
539
|
+
|
540
|
+
if (!ec)
|
541
|
+
{
|
542
|
+
// Need to set the SO_UPDATE_CONNECT_CONTEXT option so that getsockname
|
543
|
+
// and getpeername will work on the connected socket.
|
544
|
+
socket_ops::state_type state = 0;
|
545
|
+
const int so_update_connect_context = 0x7010;
|
546
|
+
socket_ops::setsockopt(s, state, SOL_SOCKET,
|
547
|
+
so_update_connect_context, 0, 0, ec);
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
#endif // defined(ASIO_HAS_IOCP)
|
552
|
+
|
553
|
+
bool non_blocking_connect(socket_type s, asio::error_code& ec)
|
554
|
+
{
|
555
|
+
// Check if the connect operation has finished. This is required since we may
|
556
|
+
// get spurious readiness notifications from the reactor.
|
557
|
+
#if defined(ASIO_WINDOWS) \
|
558
|
+
|| defined(__CYGWIN__) \
|
559
|
+
|| defined(__SYMBIAN32__)
|
560
|
+
fd_set write_fds;
|
561
|
+
FD_ZERO(&write_fds);
|
562
|
+
FD_SET(s, &write_fds);
|
563
|
+
fd_set except_fds;
|
564
|
+
FD_ZERO(&except_fds);
|
565
|
+
FD_SET(s, &except_fds);
|
566
|
+
timeval zero_timeout;
|
567
|
+
zero_timeout.tv_sec = 0;
|
568
|
+
zero_timeout.tv_usec = 0;
|
569
|
+
int ready = ::select(s + 1, 0, &write_fds, &except_fds, &zero_timeout);
|
570
|
+
#else // defined(ASIO_WINDOWS)
|
571
|
+
// || defined(__CYGWIN__)
|
572
|
+
// || defined(__SYMBIAN32__)
|
573
|
+
pollfd fds;
|
574
|
+
fds.fd = s;
|
575
|
+
fds.events = POLLOUT;
|
576
|
+
fds.revents = 0;
|
577
|
+
int ready = ::poll(&fds, 1, 0);
|
578
|
+
#endif // defined(ASIO_WINDOWS)
|
579
|
+
// || defined(__CYGWIN__)
|
580
|
+
// || defined(__SYMBIAN32__)
|
581
|
+
if (ready == 0)
|
582
|
+
{
|
583
|
+
// The asynchronous connect operation is still in progress.
|
584
|
+
return false;
|
585
|
+
}
|
586
|
+
|
587
|
+
// Get the error code from the connect operation.
|
588
|
+
int connect_error = 0;
|
589
|
+
size_t connect_error_len = sizeof(connect_error);
|
590
|
+
if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_ERROR,
|
591
|
+
&connect_error, &connect_error_len, ec) == 0)
|
592
|
+
{
|
593
|
+
if (connect_error)
|
594
|
+
{
|
595
|
+
ec = asio::error_code(connect_error,
|
596
|
+
asio::error::get_system_category());
|
597
|
+
}
|
598
|
+
else
|
599
|
+
ec.assign(0, ec.category());
|
600
|
+
}
|
601
|
+
|
602
|
+
return true;
|
603
|
+
}
|
604
|
+
|
605
|
+
int socketpair(int af, int type, int protocol,
|
606
|
+
socket_type sv[2], asio::error_code& ec)
|
607
|
+
{
|
608
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
609
|
+
(void)(af);
|
610
|
+
(void)(type);
|
611
|
+
(void)(protocol);
|
612
|
+
(void)(sv);
|
613
|
+
ec = asio::error::operation_not_supported;
|
614
|
+
return socket_error_retval;
|
615
|
+
#else
|
616
|
+
int result = ::socketpair(af, type, protocol, sv);
|
617
|
+
get_last_error(ec, result != 0);
|
618
|
+
return result;
|
619
|
+
#endif
|
620
|
+
}
|
621
|
+
|
622
|
+
bool sockatmark(socket_type s, asio::error_code& ec)
|
623
|
+
{
|
624
|
+
if (s == invalid_socket)
|
625
|
+
{
|
626
|
+
ec = asio::error::bad_descriptor;
|
627
|
+
return false;
|
628
|
+
}
|
629
|
+
|
630
|
+
#if defined(SIOCATMARK)
|
631
|
+
ioctl_arg_type value = 0;
|
632
|
+
# if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
633
|
+
int result = ::ioctlsocket(s, SIOCATMARK, &value);
|
634
|
+
# else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
635
|
+
int result = ::ioctl(s, SIOCATMARK, &value);
|
636
|
+
# endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
637
|
+
get_last_error(ec, result < 0);
|
638
|
+
# if defined(ENOTTY)
|
639
|
+
if (ec.value() == ENOTTY)
|
640
|
+
ec = asio::error::not_socket;
|
641
|
+
# endif // defined(ENOTTY)
|
642
|
+
#else // defined(SIOCATMARK)
|
643
|
+
int value = ::sockatmark(s);
|
644
|
+
get_last_error(ec, result < 0);
|
645
|
+
#endif // defined(SIOCATMARK)
|
646
|
+
|
647
|
+
return ec ? false : value != 0;
|
648
|
+
}
|
649
|
+
|
650
|
+
size_t available(socket_type s, asio::error_code& ec)
|
651
|
+
{
|
652
|
+
if (s == invalid_socket)
|
653
|
+
{
|
654
|
+
ec = asio::error::bad_descriptor;
|
655
|
+
return 0;
|
656
|
+
}
|
657
|
+
|
658
|
+
ioctl_arg_type value = 0;
|
659
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
660
|
+
int result = ::ioctlsocket(s, FIONREAD, &value);
|
661
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
662
|
+
int result = ::ioctl(s, FIONREAD, &value);
|
663
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
664
|
+
get_last_error(ec, result < 0);
|
665
|
+
#if defined(ENOTTY)
|
666
|
+
if (ec.value() == ENOTTY)
|
667
|
+
ec = asio::error::not_socket;
|
668
|
+
#endif // defined(ENOTTY)
|
669
|
+
|
670
|
+
return ec ? static_cast<size_t>(0) : static_cast<size_t>(value);
|
671
|
+
}
|
672
|
+
|
673
|
+
int listen(socket_type s, int backlog, asio::error_code& ec)
|
674
|
+
{
|
675
|
+
if (s == invalid_socket)
|
676
|
+
{
|
677
|
+
ec = asio::error::bad_descriptor;
|
678
|
+
return socket_error_retval;
|
679
|
+
}
|
680
|
+
|
681
|
+
int result = ::listen(s, backlog);
|
682
|
+
get_last_error(ec, result != 0);
|
683
|
+
return result;
|
684
|
+
}
|
685
|
+
|
686
|
+
inline void init_buf_iov_base(void*& base, void* addr)
|
687
|
+
{
|
688
|
+
base = addr;
|
689
|
+
}
|
690
|
+
|
691
|
+
template <typename T>
|
692
|
+
inline void init_buf_iov_base(T& base, void* addr)
|
693
|
+
{
|
694
|
+
base = static_cast<T>(addr);
|
695
|
+
}
|
696
|
+
|
697
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
698
|
+
typedef WSABUF buf;
|
699
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
700
|
+
typedef iovec buf;
|
701
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
702
|
+
|
703
|
+
void init_buf(buf& b, void* data, size_t size)
|
704
|
+
{
|
705
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
706
|
+
b.buf = static_cast<char*>(data);
|
707
|
+
b.len = static_cast<u_long>(size);
|
708
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
709
|
+
init_buf_iov_base(b.iov_base, data);
|
710
|
+
b.iov_len = size;
|
711
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
712
|
+
}
|
713
|
+
|
714
|
+
void init_buf(buf& b, const void* data, size_t size)
|
715
|
+
{
|
716
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
717
|
+
b.buf = static_cast<char*>(const_cast<void*>(data));
|
718
|
+
b.len = static_cast<u_long>(size);
|
719
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
720
|
+
init_buf_iov_base(b.iov_base, const_cast<void*>(data));
|
721
|
+
b.iov_len = size;
|
722
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
723
|
+
}
|
724
|
+
|
725
|
+
inline void init_msghdr_msg_name(void*& name, socket_addr_type* addr)
|
726
|
+
{
|
727
|
+
name = addr;
|
728
|
+
}
|
729
|
+
|
730
|
+
inline void init_msghdr_msg_name(void*& name, const socket_addr_type* addr)
|
731
|
+
{
|
732
|
+
name = const_cast<socket_addr_type*>(addr);
|
733
|
+
}
|
734
|
+
|
735
|
+
template <typename T>
|
736
|
+
inline void init_msghdr_msg_name(T& name, socket_addr_type* addr)
|
737
|
+
{
|
738
|
+
name = reinterpret_cast<T>(addr);
|
739
|
+
}
|
740
|
+
|
741
|
+
template <typename T>
|
742
|
+
inline void init_msghdr_msg_name(T& name, const socket_addr_type* addr)
|
743
|
+
{
|
744
|
+
name = reinterpret_cast<T>(const_cast<socket_addr_type*>(addr));
|
745
|
+
}
|
746
|
+
|
747
|
+
signed_size_type recv(socket_type s, buf* bufs, size_t count,
|
748
|
+
int flags, asio::error_code& ec)
|
749
|
+
{
|
750
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
751
|
+
// Receive some data.
|
752
|
+
DWORD recv_buf_count = static_cast<DWORD>(count);
|
753
|
+
DWORD bytes_transferred = 0;
|
754
|
+
DWORD recv_flags = flags;
|
755
|
+
int result = ::WSARecv(s, bufs, recv_buf_count,
|
756
|
+
&bytes_transferred, &recv_flags, 0, 0);
|
757
|
+
get_last_error(ec, true);
|
758
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
759
|
+
ec = asio::error::connection_reset;
|
760
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
761
|
+
ec = asio::error::connection_refused;
|
762
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
763
|
+
result = 0;
|
764
|
+
if (result != 0)
|
765
|
+
return socket_error_retval;
|
766
|
+
ec.assign(0, ec.category());
|
767
|
+
return bytes_transferred;
|
768
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
769
|
+
msghdr msg = msghdr();
|
770
|
+
msg.msg_iov = bufs;
|
771
|
+
msg.msg_iovlen = static_cast<int>(count);
|
772
|
+
signed_size_type result = ::recvmsg(s, &msg, flags);
|
773
|
+
get_last_error(ec, result < 0);
|
774
|
+
return result;
|
775
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
776
|
+
}
|
777
|
+
|
778
|
+
signed_size_type recv1(socket_type s, void* data, size_t size,
|
779
|
+
int flags, asio::error_code& ec)
|
780
|
+
{
|
781
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
782
|
+
// Receive some data.
|
783
|
+
WSABUF buf;
|
784
|
+
buf.buf = const_cast<char*>(static_cast<const char*>(data));
|
785
|
+
buf.len = static_cast<ULONG>(size);
|
786
|
+
DWORD bytes_transferred = 0;
|
787
|
+
DWORD recv_flags = flags;
|
788
|
+
int result = ::WSARecv(s, &buf, 1,
|
789
|
+
&bytes_transferred, &recv_flags, 0, 0);
|
790
|
+
get_last_error(ec, true);
|
791
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
792
|
+
ec = asio::error::connection_reset;
|
793
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
794
|
+
ec = asio::error::connection_refused;
|
795
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
796
|
+
result = 0;
|
797
|
+
if (result != 0)
|
798
|
+
return socket_error_retval;
|
799
|
+
ec.assign(0, ec.category());
|
800
|
+
return bytes_transferred;
|
801
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
802
|
+
signed_size_type result = ::recv(s, static_cast<char*>(data), size, flags);
|
803
|
+
get_last_error(ec, result < 0);
|
804
|
+
return result;
|
805
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
806
|
+
}
|
807
|
+
|
808
|
+
size_t sync_recv(socket_type s, state_type state, buf* bufs,
|
809
|
+
size_t count, int flags, bool all_empty, asio::error_code& ec)
|
810
|
+
{
|
811
|
+
if (s == invalid_socket)
|
812
|
+
{
|
813
|
+
ec = asio::error::bad_descriptor;
|
814
|
+
return 0;
|
815
|
+
}
|
816
|
+
|
817
|
+
// A request to read 0 bytes on a stream is a no-op.
|
818
|
+
if (all_empty && (state & stream_oriented))
|
819
|
+
{
|
820
|
+
ec.assign(0, ec.category());
|
821
|
+
return 0;
|
822
|
+
}
|
823
|
+
|
824
|
+
// Read some data.
|
825
|
+
for (;;)
|
826
|
+
{
|
827
|
+
// Try to complete the operation without blocking.
|
828
|
+
signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
|
829
|
+
|
830
|
+
// Check for EOF.
|
831
|
+
if ((state & stream_oriented) && bytes == 0)
|
832
|
+
{
|
833
|
+
ec = asio::error::eof;
|
834
|
+
return 0;
|
835
|
+
}
|
836
|
+
|
837
|
+
// Check if operation succeeded.
|
838
|
+
if (bytes >= 0)
|
839
|
+
return bytes;
|
840
|
+
|
841
|
+
// Operation failed.
|
842
|
+
if ((state & user_set_non_blocking)
|
843
|
+
|| (ec != asio::error::would_block
|
844
|
+
&& ec != asio::error::try_again))
|
845
|
+
return 0;
|
846
|
+
|
847
|
+
// Wait for socket to become ready.
|
848
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
849
|
+
return 0;
|
850
|
+
}
|
851
|
+
}
|
852
|
+
|
853
|
+
size_t sync_recv1(socket_type s, state_type state, void* data,
|
854
|
+
size_t size, int flags, asio::error_code& ec)
|
855
|
+
{
|
856
|
+
if (s == invalid_socket)
|
857
|
+
{
|
858
|
+
ec = asio::error::bad_descriptor;
|
859
|
+
return 0;
|
860
|
+
}
|
861
|
+
|
862
|
+
// A request to read 0 bytes on a stream is a no-op.
|
863
|
+
if (size == 0 && (state & stream_oriented))
|
864
|
+
{
|
865
|
+
ec.assign(0, ec.category());
|
866
|
+
return 0;
|
867
|
+
}
|
868
|
+
|
869
|
+
// Read some data.
|
870
|
+
for (;;)
|
871
|
+
{
|
872
|
+
// Try to complete the operation without blocking.
|
873
|
+
signed_size_type bytes = socket_ops::recv1(s, data, size, flags, ec);
|
874
|
+
|
875
|
+
// Check for EOF.
|
876
|
+
if ((state & stream_oriented) && bytes == 0)
|
877
|
+
{
|
878
|
+
ec = asio::error::eof;
|
879
|
+
return 0;
|
880
|
+
}
|
881
|
+
|
882
|
+
// Check if operation succeeded.
|
883
|
+
if (bytes >= 0)
|
884
|
+
return bytes;
|
885
|
+
|
886
|
+
// Operation failed.
|
887
|
+
if ((state & user_set_non_blocking)
|
888
|
+
|| (ec != asio::error::would_block
|
889
|
+
&& ec != asio::error::try_again))
|
890
|
+
return 0;
|
891
|
+
|
892
|
+
// Wait for socket to become ready.
|
893
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
894
|
+
return 0;
|
895
|
+
}
|
896
|
+
}
|
897
|
+
|
898
|
+
#if defined(ASIO_HAS_IOCP)
|
899
|
+
|
900
|
+
void complete_iocp_recv(state_type state,
|
901
|
+
const weak_cancel_token_type& cancel_token, bool all_empty,
|
902
|
+
asio::error_code& ec, size_t bytes_transferred)
|
903
|
+
{
|
904
|
+
// Map non-portable errors to their portable counterparts.
|
905
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
906
|
+
{
|
907
|
+
if (cancel_token.expired())
|
908
|
+
ec = asio::error::operation_aborted;
|
909
|
+
else
|
910
|
+
ec = asio::error::connection_reset;
|
911
|
+
}
|
912
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
913
|
+
{
|
914
|
+
ec = asio::error::connection_refused;
|
915
|
+
}
|
916
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
917
|
+
{
|
918
|
+
ec.assign(0, ec.category());
|
919
|
+
}
|
920
|
+
|
921
|
+
// Check for connection closed.
|
922
|
+
else if (!ec && bytes_transferred == 0
|
923
|
+
&& (state & stream_oriented) != 0
|
924
|
+
&& !all_empty)
|
925
|
+
{
|
926
|
+
ec = asio::error::eof;
|
927
|
+
}
|
928
|
+
}
|
929
|
+
|
930
|
+
#else // defined(ASIO_HAS_IOCP)
|
931
|
+
|
932
|
+
bool non_blocking_recv(socket_type s,
|
933
|
+
buf* bufs, size_t count, int flags, bool is_stream,
|
934
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
935
|
+
{
|
936
|
+
for (;;)
|
937
|
+
{
|
938
|
+
// Read some data.
|
939
|
+
signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
|
940
|
+
|
941
|
+
// Check for end of stream.
|
942
|
+
if (is_stream && bytes == 0)
|
943
|
+
{
|
944
|
+
ec = asio::error::eof;
|
945
|
+
return true;
|
946
|
+
}
|
947
|
+
|
948
|
+
// Check if operation succeeded.
|
949
|
+
if (bytes >= 0)
|
950
|
+
{
|
951
|
+
bytes_transferred = bytes;
|
952
|
+
return true;
|
953
|
+
}
|
954
|
+
|
955
|
+
// Retry operation if interrupted by signal.
|
956
|
+
if (ec == asio::error::interrupted)
|
957
|
+
continue;
|
958
|
+
|
959
|
+
// Check if we need to run the operation again.
|
960
|
+
if (ec == asio::error::would_block
|
961
|
+
|| ec == asio::error::try_again)
|
962
|
+
return false;
|
963
|
+
|
964
|
+
// Operation failed.
|
965
|
+
bytes_transferred = 0;
|
966
|
+
return true;
|
967
|
+
}
|
968
|
+
}
|
969
|
+
|
970
|
+
bool non_blocking_recv1(socket_type s,
|
971
|
+
void* data, size_t size, int flags, bool is_stream,
|
972
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
973
|
+
{
|
974
|
+
for (;;)
|
975
|
+
{
|
976
|
+
// Read some data.
|
977
|
+
signed_size_type bytes = socket_ops::recv1(s, data, size, flags, ec);
|
978
|
+
|
979
|
+
// Check for end of stream.
|
980
|
+
if (is_stream && bytes == 0)
|
981
|
+
{
|
982
|
+
ec = asio::error::eof;
|
983
|
+
return true;
|
984
|
+
}
|
985
|
+
|
986
|
+
// Check if operation succeeded.
|
987
|
+
if (bytes >= 0)
|
988
|
+
{
|
989
|
+
bytes_transferred = bytes;
|
990
|
+
return true;
|
991
|
+
}
|
992
|
+
|
993
|
+
// Retry operation if interrupted by signal.
|
994
|
+
if (ec == asio::error::interrupted)
|
995
|
+
continue;
|
996
|
+
|
997
|
+
// Check if we need to run the operation again.
|
998
|
+
if (ec == asio::error::would_block
|
999
|
+
|| ec == asio::error::try_again)
|
1000
|
+
return false;
|
1001
|
+
|
1002
|
+
// Operation failed.
|
1003
|
+
bytes_transferred = 0;
|
1004
|
+
return true;
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
#endif // defined(ASIO_HAS_IOCP)
|
1009
|
+
|
1010
|
+
signed_size_type recvfrom(socket_type s, buf* bufs, size_t count,
|
1011
|
+
int flags, socket_addr_type* addr, std::size_t* addrlen,
|
1012
|
+
asio::error_code& ec)
|
1013
|
+
{
|
1014
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1015
|
+
// Receive some data.
|
1016
|
+
DWORD recv_buf_count = static_cast<DWORD>(count);
|
1017
|
+
DWORD bytes_transferred = 0;
|
1018
|
+
DWORD recv_flags = flags;
|
1019
|
+
int tmp_addrlen = (int)*addrlen;
|
1020
|
+
int result = ::WSARecvFrom(s, bufs, recv_buf_count,
|
1021
|
+
&bytes_transferred, &recv_flags, addr, &tmp_addrlen, 0, 0);
|
1022
|
+
get_last_error(ec, true);
|
1023
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
1024
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1025
|
+
ec = asio::error::connection_reset;
|
1026
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1027
|
+
ec = asio::error::connection_refused;
|
1028
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
1029
|
+
result = 0;
|
1030
|
+
if (result != 0)
|
1031
|
+
return socket_error_retval;
|
1032
|
+
ec.assign(0, ec.category());
|
1033
|
+
return bytes_transferred;
|
1034
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1035
|
+
msghdr msg = msghdr();
|
1036
|
+
init_msghdr_msg_name(msg.msg_name, addr);
|
1037
|
+
msg.msg_namelen = static_cast<int>(*addrlen);
|
1038
|
+
msg.msg_iov = bufs;
|
1039
|
+
msg.msg_iovlen = static_cast<int>(count);
|
1040
|
+
signed_size_type result = ::recvmsg(s, &msg, flags);
|
1041
|
+
get_last_error(ec, result < 0);
|
1042
|
+
*addrlen = msg.msg_namelen;
|
1043
|
+
return result;
|
1044
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
template <typename SockLenType>
|
1048
|
+
inline signed_size_type call_recvfrom(SockLenType msghdr::*,
|
1049
|
+
socket_type s, void* data, size_t size, int flags,
|
1050
|
+
socket_addr_type* addr, std::size_t* addrlen)
|
1051
|
+
{
|
1052
|
+
SockLenType tmp_addrlen = addrlen ? (SockLenType)*addrlen : 0;
|
1053
|
+
signed_size_type result = ::recvfrom(s, static_cast<char*>(data),
|
1054
|
+
size, flags, addr, addrlen ? &tmp_addrlen : 0);
|
1055
|
+
if (addrlen)
|
1056
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
1057
|
+
return result;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
signed_size_type recvfrom1(socket_type s, void* data, size_t size,
|
1061
|
+
int flags, socket_addr_type* addr, std::size_t* addrlen,
|
1062
|
+
asio::error_code& ec)
|
1063
|
+
{
|
1064
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1065
|
+
// Receive some data.
|
1066
|
+
WSABUF buf;
|
1067
|
+
buf.buf = static_cast<char*>(data);
|
1068
|
+
buf.len = static_cast<ULONG>(size);
|
1069
|
+
DWORD bytes_transferred = 0;
|
1070
|
+
DWORD recv_flags = flags;
|
1071
|
+
int tmp_addrlen = (int)*addrlen;
|
1072
|
+
int result = ::WSARecvFrom(s, &buf, 1, &bytes_transferred,
|
1073
|
+
&recv_flags, addr, &tmp_addrlen, 0, 0);
|
1074
|
+
get_last_error(ec, true);
|
1075
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
1076
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1077
|
+
ec = asio::error::connection_reset;
|
1078
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1079
|
+
ec = asio::error::connection_refused;
|
1080
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
1081
|
+
result = 0;
|
1082
|
+
if (result != 0)
|
1083
|
+
return socket_error_retval;
|
1084
|
+
ec.assign(0, ec.category());
|
1085
|
+
return bytes_transferred;
|
1086
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1087
|
+
signed_size_type result = call_recvfrom(&msghdr::msg_namelen,
|
1088
|
+
s, data, size, flags, addr, addrlen);
|
1089
|
+
get_last_error(ec, result < 0);
|
1090
|
+
return result;
|
1091
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
size_t sync_recvfrom(socket_type s, state_type state, buf* bufs,
|
1095
|
+
size_t count, int flags, socket_addr_type* addr,
|
1096
|
+
std::size_t* addrlen, asio::error_code& ec)
|
1097
|
+
{
|
1098
|
+
if (s == invalid_socket)
|
1099
|
+
{
|
1100
|
+
ec = asio::error::bad_descriptor;
|
1101
|
+
return 0;
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
// Read some data.
|
1105
|
+
for (;;)
|
1106
|
+
{
|
1107
|
+
// Try to complete the operation without blocking.
|
1108
|
+
signed_size_type bytes = socket_ops::recvfrom(
|
1109
|
+
s, bufs, count, flags, addr, addrlen, ec);
|
1110
|
+
|
1111
|
+
// Check if operation succeeded.
|
1112
|
+
if (bytes >= 0)
|
1113
|
+
return bytes;
|
1114
|
+
|
1115
|
+
// Operation failed.
|
1116
|
+
if ((state & user_set_non_blocking)
|
1117
|
+
|| (ec != asio::error::would_block
|
1118
|
+
&& ec != asio::error::try_again))
|
1119
|
+
return 0;
|
1120
|
+
|
1121
|
+
// Wait for socket to become ready.
|
1122
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
1123
|
+
return 0;
|
1124
|
+
}
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
size_t sync_recvfrom1(socket_type s, state_type state, void* data,
|
1128
|
+
size_t size, int flags, socket_addr_type* addr,
|
1129
|
+
std::size_t* addrlen, asio::error_code& ec)
|
1130
|
+
{
|
1131
|
+
if (s == invalid_socket)
|
1132
|
+
{
|
1133
|
+
ec = asio::error::bad_descriptor;
|
1134
|
+
return 0;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
// Read some data.
|
1138
|
+
for (;;)
|
1139
|
+
{
|
1140
|
+
// Try to complete the operation without blocking.
|
1141
|
+
signed_size_type bytes = socket_ops::recvfrom1(
|
1142
|
+
s, data, size, flags, addr, addrlen, ec);
|
1143
|
+
|
1144
|
+
// Check if operation succeeded.
|
1145
|
+
if (bytes >= 0)
|
1146
|
+
return bytes;
|
1147
|
+
|
1148
|
+
// Operation failed.
|
1149
|
+
if ((state & user_set_non_blocking)
|
1150
|
+
|| (ec != asio::error::would_block
|
1151
|
+
&& ec != asio::error::try_again))
|
1152
|
+
return 0;
|
1153
|
+
|
1154
|
+
// Wait for socket to become ready.
|
1155
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
1156
|
+
return 0;
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
#if defined(ASIO_HAS_IOCP)
|
1161
|
+
|
1162
|
+
void complete_iocp_recvfrom(
|
1163
|
+
const weak_cancel_token_type& cancel_token,
|
1164
|
+
asio::error_code& ec)
|
1165
|
+
{
|
1166
|
+
// Map non-portable errors to their portable counterparts.
|
1167
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1168
|
+
{
|
1169
|
+
if (cancel_token.expired())
|
1170
|
+
ec = asio::error::operation_aborted;
|
1171
|
+
else
|
1172
|
+
ec = asio::error::connection_reset;
|
1173
|
+
}
|
1174
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1175
|
+
{
|
1176
|
+
ec = asio::error::connection_refused;
|
1177
|
+
}
|
1178
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
1179
|
+
{
|
1180
|
+
ec.assign(0, ec.category());
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
|
1184
|
+
#else // defined(ASIO_HAS_IOCP)
|
1185
|
+
|
1186
|
+
bool non_blocking_recvfrom(socket_type s,
|
1187
|
+
buf* bufs, size_t count, int flags,
|
1188
|
+
socket_addr_type* addr, std::size_t* addrlen,
|
1189
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1190
|
+
{
|
1191
|
+
for (;;)
|
1192
|
+
{
|
1193
|
+
// Read some data.
|
1194
|
+
signed_size_type bytes = socket_ops::recvfrom(
|
1195
|
+
s, bufs, count, flags, addr, addrlen, ec);
|
1196
|
+
|
1197
|
+
// Check if operation succeeded.
|
1198
|
+
if (bytes >= 0)
|
1199
|
+
{
|
1200
|
+
bytes_transferred = bytes;
|
1201
|
+
return true;
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
// Retry operation if interrupted by signal.
|
1205
|
+
if (ec == asio::error::interrupted)
|
1206
|
+
continue;
|
1207
|
+
|
1208
|
+
// Check if we need to run the operation again.
|
1209
|
+
if (ec == asio::error::would_block
|
1210
|
+
|| ec == asio::error::try_again)
|
1211
|
+
return false;
|
1212
|
+
|
1213
|
+
// Operation failed.
|
1214
|
+
bytes_transferred = 0;
|
1215
|
+
return true;
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
bool non_blocking_recvfrom1(socket_type s,
|
1220
|
+
void* data, size_t size, int flags,
|
1221
|
+
socket_addr_type* addr, std::size_t* addrlen,
|
1222
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1223
|
+
{
|
1224
|
+
for (;;)
|
1225
|
+
{
|
1226
|
+
// Read some data.
|
1227
|
+
signed_size_type bytes = socket_ops::recvfrom1(
|
1228
|
+
s, data, size, flags, addr, addrlen, ec);
|
1229
|
+
|
1230
|
+
// Check if operation succeeded.
|
1231
|
+
if (bytes >= 0)
|
1232
|
+
{
|
1233
|
+
bytes_transferred = bytes;
|
1234
|
+
return true;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
// Retry operation if interrupted by signal.
|
1238
|
+
if (ec == asio::error::interrupted)
|
1239
|
+
continue;
|
1240
|
+
|
1241
|
+
// Check if we need to run the operation again.
|
1242
|
+
if (ec == asio::error::would_block
|
1243
|
+
|| ec == asio::error::try_again)
|
1244
|
+
return false;
|
1245
|
+
|
1246
|
+
// Operation failed.
|
1247
|
+
bytes_transferred = 0;
|
1248
|
+
return true;
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
#endif // defined(ASIO_HAS_IOCP)
|
1253
|
+
|
1254
|
+
signed_size_type recvmsg(socket_type s, buf* bufs, size_t count,
|
1255
|
+
int in_flags, int& out_flags, asio::error_code& ec)
|
1256
|
+
{
|
1257
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1258
|
+
out_flags = 0;
|
1259
|
+
return socket_ops::recv(s, bufs, count, in_flags, ec);
|
1260
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1261
|
+
msghdr msg = msghdr();
|
1262
|
+
msg.msg_iov = bufs;
|
1263
|
+
msg.msg_iovlen = static_cast<int>(count);
|
1264
|
+
signed_size_type result = ::recvmsg(s, &msg, in_flags);
|
1265
|
+
get_last_error(ec, result < 0);
|
1266
|
+
if (result >= 0)
|
1267
|
+
out_flags = msg.msg_flags;
|
1268
|
+
else
|
1269
|
+
out_flags = 0;
|
1270
|
+
return result;
|
1271
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
size_t sync_recvmsg(socket_type s, state_type state,
|
1275
|
+
buf* bufs, size_t count, int in_flags, int& out_flags,
|
1276
|
+
asio::error_code& ec)
|
1277
|
+
{
|
1278
|
+
if (s == invalid_socket)
|
1279
|
+
{
|
1280
|
+
ec = asio::error::bad_descriptor;
|
1281
|
+
return 0;
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
// Read some data.
|
1285
|
+
for (;;)
|
1286
|
+
{
|
1287
|
+
// Try to complete the operation without blocking.
|
1288
|
+
signed_size_type bytes = socket_ops::recvmsg(
|
1289
|
+
s, bufs, count, in_flags, out_flags, ec);
|
1290
|
+
|
1291
|
+
// Check if operation succeeded.
|
1292
|
+
if (bytes >= 0)
|
1293
|
+
return bytes;
|
1294
|
+
|
1295
|
+
// Operation failed.
|
1296
|
+
if ((state & user_set_non_blocking)
|
1297
|
+
|| (ec != asio::error::would_block
|
1298
|
+
&& ec != asio::error::try_again))
|
1299
|
+
return 0;
|
1300
|
+
|
1301
|
+
// Wait for socket to become ready.
|
1302
|
+
if (socket_ops::poll_read(s, 0, -1, ec) < 0)
|
1303
|
+
return 0;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
#if defined(ASIO_HAS_IOCP)
|
1308
|
+
|
1309
|
+
void complete_iocp_recvmsg(
|
1310
|
+
const weak_cancel_token_type& cancel_token,
|
1311
|
+
asio::error_code& ec)
|
1312
|
+
{
|
1313
|
+
// Map non-portable errors to their portable counterparts.
|
1314
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1315
|
+
{
|
1316
|
+
if (cancel_token.expired())
|
1317
|
+
ec = asio::error::operation_aborted;
|
1318
|
+
else
|
1319
|
+
ec = asio::error::connection_reset;
|
1320
|
+
}
|
1321
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1322
|
+
{
|
1323
|
+
ec = asio::error::connection_refused;
|
1324
|
+
}
|
1325
|
+
else if (ec.value() == WSAEMSGSIZE || ec.value() == ERROR_MORE_DATA)
|
1326
|
+
{
|
1327
|
+
ec.assign(0, ec.category());
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
#else // defined(ASIO_HAS_IOCP)
|
1332
|
+
|
1333
|
+
bool non_blocking_recvmsg(socket_type s,
|
1334
|
+
buf* bufs, size_t count, int in_flags, int& out_flags,
|
1335
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1336
|
+
{
|
1337
|
+
for (;;)
|
1338
|
+
{
|
1339
|
+
// Read some data.
|
1340
|
+
signed_size_type bytes = socket_ops::recvmsg(
|
1341
|
+
s, bufs, count, in_flags, out_flags, ec);
|
1342
|
+
|
1343
|
+
// Check if operation succeeded.
|
1344
|
+
if (bytes >= 0)
|
1345
|
+
{
|
1346
|
+
bytes_transferred = bytes;
|
1347
|
+
return true;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
// Retry operation if interrupted by signal.
|
1351
|
+
if (ec == asio::error::interrupted)
|
1352
|
+
continue;
|
1353
|
+
|
1354
|
+
// Check if we need to run the operation again.
|
1355
|
+
if (ec == asio::error::would_block
|
1356
|
+
|| ec == asio::error::try_again)
|
1357
|
+
return false;
|
1358
|
+
|
1359
|
+
// Operation failed.
|
1360
|
+
bytes_transferred = 0;
|
1361
|
+
return true;
|
1362
|
+
}
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
#endif // defined(ASIO_HAS_IOCP)
|
1366
|
+
|
1367
|
+
signed_size_type send(socket_type s, const buf* bufs, size_t count,
|
1368
|
+
int flags, asio::error_code& ec)
|
1369
|
+
{
|
1370
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1371
|
+
// Send the data.
|
1372
|
+
DWORD send_buf_count = static_cast<DWORD>(count);
|
1373
|
+
DWORD bytes_transferred = 0;
|
1374
|
+
DWORD send_flags = flags;
|
1375
|
+
int result = ::WSASend(s, const_cast<buf*>(bufs),
|
1376
|
+
send_buf_count, &bytes_transferred, send_flags, 0, 0);
|
1377
|
+
get_last_error(ec, true);
|
1378
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1379
|
+
ec = asio::error::connection_reset;
|
1380
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1381
|
+
ec = asio::error::connection_refused;
|
1382
|
+
if (result != 0)
|
1383
|
+
return socket_error_retval;
|
1384
|
+
ec.assign(0, ec.category());
|
1385
|
+
return bytes_transferred;
|
1386
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1387
|
+
msghdr msg = msghdr();
|
1388
|
+
msg.msg_iov = const_cast<buf*>(bufs);
|
1389
|
+
msg.msg_iovlen = static_cast<int>(count);
|
1390
|
+
#if defined(__linux__)
|
1391
|
+
flags |= MSG_NOSIGNAL;
|
1392
|
+
#endif // defined(__linux__)
|
1393
|
+
signed_size_type result = ::sendmsg(s, &msg, flags);
|
1394
|
+
get_last_error(ec, result < 0);
|
1395
|
+
return result;
|
1396
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
signed_size_type send1(socket_type s, const void* data, size_t size,
|
1400
|
+
int flags, asio::error_code& ec)
|
1401
|
+
{
|
1402
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1403
|
+
// Send the data.
|
1404
|
+
WSABUF buf;
|
1405
|
+
buf.buf = const_cast<char*>(static_cast<const char*>(data));
|
1406
|
+
buf.len = static_cast<ULONG>(size);
|
1407
|
+
DWORD bytes_transferred = 0;
|
1408
|
+
DWORD send_flags = flags;
|
1409
|
+
int result = ::WSASend(s, &buf, 1,
|
1410
|
+
&bytes_transferred, send_flags, 0, 0);
|
1411
|
+
get_last_error(ec, true);
|
1412
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1413
|
+
ec = asio::error::connection_reset;
|
1414
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1415
|
+
ec = asio::error::connection_refused;
|
1416
|
+
if (result != 0)
|
1417
|
+
return socket_error_retval;
|
1418
|
+
ec.assign(0, ec.category());
|
1419
|
+
return bytes_transferred;
|
1420
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1421
|
+
#if defined(__linux__)
|
1422
|
+
flags |= MSG_NOSIGNAL;
|
1423
|
+
#endif // defined(__linux__)
|
1424
|
+
signed_size_type result = ::send(s,
|
1425
|
+
static_cast<const char*>(data), size, flags);
|
1426
|
+
get_last_error(ec, result < 0);
|
1427
|
+
return result;
|
1428
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1429
|
+
}
|
1430
|
+
|
1431
|
+
size_t sync_send(socket_type s, state_type state, const buf* bufs,
|
1432
|
+
size_t count, int flags, bool all_empty, asio::error_code& ec)
|
1433
|
+
{
|
1434
|
+
if (s == invalid_socket)
|
1435
|
+
{
|
1436
|
+
ec = asio::error::bad_descriptor;
|
1437
|
+
return 0;
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
// A request to write 0 bytes to a stream is a no-op.
|
1441
|
+
if (all_empty && (state & stream_oriented))
|
1442
|
+
{
|
1443
|
+
ec.assign(0, ec.category());
|
1444
|
+
return 0;
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
// Read some data.
|
1448
|
+
for (;;)
|
1449
|
+
{
|
1450
|
+
// Try to complete the operation without blocking.
|
1451
|
+
signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
|
1452
|
+
|
1453
|
+
// Check if operation succeeded.
|
1454
|
+
if (bytes >= 0)
|
1455
|
+
return bytes;
|
1456
|
+
|
1457
|
+
// Operation failed.
|
1458
|
+
if ((state & user_set_non_blocking)
|
1459
|
+
|| (ec != asio::error::would_block
|
1460
|
+
&& ec != asio::error::try_again))
|
1461
|
+
return 0;
|
1462
|
+
|
1463
|
+
// Wait for socket to become ready.
|
1464
|
+
if (socket_ops::poll_write(s, 0, -1, ec) < 0)
|
1465
|
+
return 0;
|
1466
|
+
}
|
1467
|
+
}
|
1468
|
+
|
1469
|
+
size_t sync_send1(socket_type s, state_type state, const void* data,
|
1470
|
+
size_t size, int flags, asio::error_code& ec)
|
1471
|
+
{
|
1472
|
+
if (s == invalid_socket)
|
1473
|
+
{
|
1474
|
+
ec = asio::error::bad_descriptor;
|
1475
|
+
return 0;
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
// A request to write 0 bytes to a stream is a no-op.
|
1479
|
+
if (size == 0 && (state & stream_oriented))
|
1480
|
+
{
|
1481
|
+
ec.assign(0, ec.category());
|
1482
|
+
return 0;
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
// Read some data.
|
1486
|
+
for (;;)
|
1487
|
+
{
|
1488
|
+
// Try to complete the operation without blocking.
|
1489
|
+
signed_size_type bytes = socket_ops::send1(s, data, size, flags, ec);
|
1490
|
+
|
1491
|
+
// Check if operation succeeded.
|
1492
|
+
if (bytes >= 0)
|
1493
|
+
return bytes;
|
1494
|
+
|
1495
|
+
// Operation failed.
|
1496
|
+
if ((state & user_set_non_blocking)
|
1497
|
+
|| (ec != asio::error::would_block
|
1498
|
+
&& ec != asio::error::try_again))
|
1499
|
+
return 0;
|
1500
|
+
|
1501
|
+
// Wait for socket to become ready.
|
1502
|
+
if (socket_ops::poll_write(s, 0, -1, ec) < 0)
|
1503
|
+
return 0;
|
1504
|
+
}
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
#if defined(ASIO_HAS_IOCP)
|
1508
|
+
|
1509
|
+
void complete_iocp_send(
|
1510
|
+
const weak_cancel_token_type& cancel_token,
|
1511
|
+
asio::error_code& ec)
|
1512
|
+
{
|
1513
|
+
// Map non-portable errors to their portable counterparts.
|
1514
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1515
|
+
{
|
1516
|
+
if (cancel_token.expired())
|
1517
|
+
ec = asio::error::operation_aborted;
|
1518
|
+
else
|
1519
|
+
ec = asio::error::connection_reset;
|
1520
|
+
}
|
1521
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1522
|
+
{
|
1523
|
+
ec = asio::error::connection_refused;
|
1524
|
+
}
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
#else // defined(ASIO_HAS_IOCP)
|
1528
|
+
|
1529
|
+
bool non_blocking_send(socket_type s,
|
1530
|
+
const buf* bufs, size_t count, int flags,
|
1531
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1532
|
+
{
|
1533
|
+
for (;;)
|
1534
|
+
{
|
1535
|
+
// Write some data.
|
1536
|
+
signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
|
1537
|
+
|
1538
|
+
// Check if operation succeeded.
|
1539
|
+
if (bytes >= 0)
|
1540
|
+
{
|
1541
|
+
bytes_transferred = bytes;
|
1542
|
+
return true;
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
// Retry operation if interrupted by signal.
|
1546
|
+
if (ec == asio::error::interrupted)
|
1547
|
+
continue;
|
1548
|
+
|
1549
|
+
// Check if we need to run the operation again.
|
1550
|
+
if (ec == asio::error::would_block
|
1551
|
+
|| ec == asio::error::try_again)
|
1552
|
+
return false;
|
1553
|
+
|
1554
|
+
// Operation failed.
|
1555
|
+
bytes_transferred = 0;
|
1556
|
+
return true;
|
1557
|
+
}
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
bool non_blocking_send1(socket_type s,
|
1561
|
+
const void* data, size_t size, int flags,
|
1562
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1563
|
+
{
|
1564
|
+
for (;;)
|
1565
|
+
{
|
1566
|
+
// Write some data.
|
1567
|
+
signed_size_type bytes = socket_ops::send1(s, data, size, flags, ec);
|
1568
|
+
|
1569
|
+
// Check if operation succeeded.
|
1570
|
+
if (bytes >= 0)
|
1571
|
+
{
|
1572
|
+
bytes_transferred = bytes;
|
1573
|
+
return true;
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
// Retry operation if interrupted by signal.
|
1577
|
+
if (ec == asio::error::interrupted)
|
1578
|
+
continue;
|
1579
|
+
|
1580
|
+
// Check if we need to run the operation again.
|
1581
|
+
if (ec == asio::error::would_block
|
1582
|
+
|| ec == asio::error::try_again)
|
1583
|
+
return false;
|
1584
|
+
|
1585
|
+
// Operation failed.
|
1586
|
+
bytes_transferred = 0;
|
1587
|
+
return true;
|
1588
|
+
}
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
#endif // defined(ASIO_HAS_IOCP)
|
1592
|
+
|
1593
|
+
signed_size_type sendto(socket_type s, const buf* bufs, size_t count,
|
1594
|
+
int flags, const socket_addr_type* addr, std::size_t addrlen,
|
1595
|
+
asio::error_code& ec)
|
1596
|
+
{
|
1597
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1598
|
+
// Send the data.
|
1599
|
+
DWORD send_buf_count = static_cast<DWORD>(count);
|
1600
|
+
DWORD bytes_transferred = 0;
|
1601
|
+
int result = ::WSASendTo(s, const_cast<buf*>(bufs),
|
1602
|
+
send_buf_count, &bytes_transferred, flags, addr,
|
1603
|
+
static_cast<int>(addrlen), 0, 0);
|
1604
|
+
get_last_error(ec, true);
|
1605
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1606
|
+
ec = asio::error::connection_reset;
|
1607
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1608
|
+
ec = asio::error::connection_refused;
|
1609
|
+
if (result != 0)
|
1610
|
+
return socket_error_retval;
|
1611
|
+
ec.assign(0, ec.category());
|
1612
|
+
return bytes_transferred;
|
1613
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1614
|
+
msghdr msg = msghdr();
|
1615
|
+
init_msghdr_msg_name(msg.msg_name, addr);
|
1616
|
+
msg.msg_namelen = static_cast<int>(addrlen);
|
1617
|
+
msg.msg_iov = const_cast<buf*>(bufs);
|
1618
|
+
msg.msg_iovlen = static_cast<int>(count);
|
1619
|
+
#if defined(__linux__)
|
1620
|
+
flags |= MSG_NOSIGNAL;
|
1621
|
+
#endif // defined(__linux__)
|
1622
|
+
signed_size_type result = ::sendmsg(s, &msg, flags);
|
1623
|
+
get_last_error(ec, result < 0);
|
1624
|
+
return result;
|
1625
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
template <typename SockLenType>
|
1629
|
+
inline signed_size_type call_sendto(SockLenType msghdr::*,
|
1630
|
+
socket_type s, const void* data, size_t size, int flags,
|
1631
|
+
const socket_addr_type* addr, std::size_t addrlen)
|
1632
|
+
{
|
1633
|
+
return ::sendto(s, static_cast<char*>(const_cast<void*>(data)),
|
1634
|
+
size, flags, addr, (SockLenType)addrlen);
|
1635
|
+
}
|
1636
|
+
|
1637
|
+
signed_size_type sendto1(socket_type s, const void* data, size_t size,
|
1638
|
+
int flags, const socket_addr_type* addr, std::size_t addrlen,
|
1639
|
+
asio::error_code& ec)
|
1640
|
+
{
|
1641
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1642
|
+
// Send the data.
|
1643
|
+
WSABUF buf;
|
1644
|
+
buf.buf = const_cast<char*>(static_cast<const char*>(data));
|
1645
|
+
buf.len = static_cast<ULONG>(size);
|
1646
|
+
DWORD bytes_transferred = 0;
|
1647
|
+
int result = ::WSASendTo(s, &buf, 1, &bytes_transferred,
|
1648
|
+
flags, addr, static_cast<int>(addrlen), 0, 0);
|
1649
|
+
get_last_error(ec, true);
|
1650
|
+
if (ec.value() == ERROR_NETNAME_DELETED)
|
1651
|
+
ec = asio::error::connection_reset;
|
1652
|
+
else if (ec.value() == ERROR_PORT_UNREACHABLE)
|
1653
|
+
ec = asio::error::connection_refused;
|
1654
|
+
if (result != 0)
|
1655
|
+
return socket_error_retval;
|
1656
|
+
ec.assign(0, ec.category());
|
1657
|
+
return bytes_transferred;
|
1658
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1659
|
+
#if defined(__linux__)
|
1660
|
+
flags |= MSG_NOSIGNAL;
|
1661
|
+
#endif // defined(__linux__)
|
1662
|
+
signed_size_type result = call_sendto(&msghdr::msg_namelen,
|
1663
|
+
s, data, size, flags, addr, addrlen);
|
1664
|
+
get_last_error(ec, result < 0);
|
1665
|
+
return result;
|
1666
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
size_t sync_sendto(socket_type s, state_type state, const buf* bufs,
|
1670
|
+
size_t count, int flags, const socket_addr_type* addr,
|
1671
|
+
std::size_t addrlen, asio::error_code& ec)
|
1672
|
+
{
|
1673
|
+
if (s == invalid_socket)
|
1674
|
+
{
|
1675
|
+
ec = asio::error::bad_descriptor;
|
1676
|
+
return 0;
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
// Write some data.
|
1680
|
+
for (;;)
|
1681
|
+
{
|
1682
|
+
// Try to complete the operation without blocking.
|
1683
|
+
signed_size_type bytes = socket_ops::sendto(
|
1684
|
+
s, bufs, count, flags, addr, addrlen, ec);
|
1685
|
+
|
1686
|
+
// Check if operation succeeded.
|
1687
|
+
if (bytes >= 0)
|
1688
|
+
return bytes;
|
1689
|
+
|
1690
|
+
// Operation failed.
|
1691
|
+
if ((state & user_set_non_blocking)
|
1692
|
+
|| (ec != asio::error::would_block
|
1693
|
+
&& ec != asio::error::try_again))
|
1694
|
+
return 0;
|
1695
|
+
|
1696
|
+
// Wait for socket to become ready.
|
1697
|
+
if (socket_ops::poll_write(s, 0, -1, ec) < 0)
|
1698
|
+
return 0;
|
1699
|
+
}
|
1700
|
+
}
|
1701
|
+
|
1702
|
+
size_t sync_sendto1(socket_type s, state_type state, const void* data,
|
1703
|
+
size_t size, int flags, const socket_addr_type* addr,
|
1704
|
+
std::size_t addrlen, asio::error_code& ec)
|
1705
|
+
{
|
1706
|
+
if (s == invalid_socket)
|
1707
|
+
{
|
1708
|
+
ec = asio::error::bad_descriptor;
|
1709
|
+
return 0;
|
1710
|
+
}
|
1711
|
+
|
1712
|
+
// Write some data.
|
1713
|
+
for (;;)
|
1714
|
+
{
|
1715
|
+
// Try to complete the operation without blocking.
|
1716
|
+
signed_size_type bytes = socket_ops::sendto1(
|
1717
|
+
s, data, size, flags, addr, addrlen, ec);
|
1718
|
+
|
1719
|
+
// Check if operation succeeded.
|
1720
|
+
if (bytes >= 0)
|
1721
|
+
return bytes;
|
1722
|
+
|
1723
|
+
// Operation failed.
|
1724
|
+
if ((state & user_set_non_blocking)
|
1725
|
+
|| (ec != asio::error::would_block
|
1726
|
+
&& ec != asio::error::try_again))
|
1727
|
+
return 0;
|
1728
|
+
|
1729
|
+
// Wait for socket to become ready.
|
1730
|
+
if (socket_ops::poll_write(s, 0, -1, ec) < 0)
|
1731
|
+
return 0;
|
1732
|
+
}
|
1733
|
+
}
|
1734
|
+
|
1735
|
+
#if !defined(ASIO_HAS_IOCP)
|
1736
|
+
|
1737
|
+
bool non_blocking_sendto(socket_type s,
|
1738
|
+
const buf* bufs, size_t count, int flags,
|
1739
|
+
const socket_addr_type* addr, std::size_t addrlen,
|
1740
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1741
|
+
{
|
1742
|
+
for (;;)
|
1743
|
+
{
|
1744
|
+
// Write some data.
|
1745
|
+
signed_size_type bytes = socket_ops::sendto(
|
1746
|
+
s, bufs, count, flags, addr, addrlen, ec);
|
1747
|
+
|
1748
|
+
// Check if operation succeeded.
|
1749
|
+
if (bytes >= 0)
|
1750
|
+
{
|
1751
|
+
bytes_transferred = bytes;
|
1752
|
+
return true;
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
// Retry operation if interrupted by signal.
|
1756
|
+
if (ec == asio::error::interrupted)
|
1757
|
+
continue;
|
1758
|
+
|
1759
|
+
// Check if we need to run the operation again.
|
1760
|
+
if (ec == asio::error::would_block
|
1761
|
+
|| ec == asio::error::try_again)
|
1762
|
+
return false;
|
1763
|
+
|
1764
|
+
// Operation failed.
|
1765
|
+
bytes_transferred = 0;
|
1766
|
+
return true;
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
|
1770
|
+
bool non_blocking_sendto1(socket_type s,
|
1771
|
+
const void* data, size_t size, int flags,
|
1772
|
+
const socket_addr_type* addr, std::size_t addrlen,
|
1773
|
+
asio::error_code& ec, size_t& bytes_transferred)
|
1774
|
+
{
|
1775
|
+
for (;;)
|
1776
|
+
{
|
1777
|
+
// Write some data.
|
1778
|
+
signed_size_type bytes = socket_ops::sendto1(
|
1779
|
+
s, data, size, flags, addr, addrlen, ec);
|
1780
|
+
|
1781
|
+
// Check if operation succeeded.
|
1782
|
+
if (bytes >= 0)
|
1783
|
+
{
|
1784
|
+
bytes_transferred = bytes;
|
1785
|
+
return true;
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
// Retry operation if interrupted by signal.
|
1789
|
+
if (ec == asio::error::interrupted)
|
1790
|
+
continue;
|
1791
|
+
|
1792
|
+
// Check if we need to run the operation again.
|
1793
|
+
if (ec == asio::error::would_block
|
1794
|
+
|| ec == asio::error::try_again)
|
1795
|
+
return false;
|
1796
|
+
|
1797
|
+
// Operation failed.
|
1798
|
+
bytes_transferred = 0;
|
1799
|
+
return true;
|
1800
|
+
}
|
1801
|
+
}
|
1802
|
+
|
1803
|
+
#endif // !defined(ASIO_HAS_IOCP)
|
1804
|
+
|
1805
|
+
socket_type socket(int af, int type, int protocol,
|
1806
|
+
asio::error_code& ec)
|
1807
|
+
{
|
1808
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
1809
|
+
socket_type s = ::WSASocketW(af, type, protocol, 0, 0, WSA_FLAG_OVERLAPPED);
|
1810
|
+
get_last_error(ec, s == invalid_socket);
|
1811
|
+
if (s == invalid_socket)
|
1812
|
+
return s;
|
1813
|
+
|
1814
|
+
if (af == ASIO_OS_DEF(AF_INET6))
|
1815
|
+
{
|
1816
|
+
// Try to enable the POSIX default behaviour of having IPV6_V6ONLY set to
|
1817
|
+
// false. This will only succeed on Windows Vista and later versions of
|
1818
|
+
// Windows, where a dual-stack IPv4/v6 implementation is available.
|
1819
|
+
DWORD optval = 0;
|
1820
|
+
::setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
|
1821
|
+
reinterpret_cast<const char*>(&optval), sizeof(optval));
|
1822
|
+
}
|
1823
|
+
|
1824
|
+
return s;
|
1825
|
+
#elif defined(__MACH__) && defined(__APPLE__) || defined(__FreeBSD__)
|
1826
|
+
socket_type s = ::socket(af, type, protocol);
|
1827
|
+
get_last_error(ec, s < 0);
|
1828
|
+
|
1829
|
+
int optval = 1;
|
1830
|
+
int result = ::setsockopt(s, SOL_SOCKET,
|
1831
|
+
SO_NOSIGPIPE, &optval, sizeof(optval));
|
1832
|
+
get_last_error(ec, result != 0);
|
1833
|
+
if (result != 0)
|
1834
|
+
{
|
1835
|
+
::close(s);
|
1836
|
+
return invalid_socket;
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
return s;
|
1840
|
+
#else
|
1841
|
+
int s = ::socket(af, type, protocol);
|
1842
|
+
get_last_error(ec, s < 0);
|
1843
|
+
return s;
|
1844
|
+
#endif
|
1845
|
+
}
|
1846
|
+
|
1847
|
+
template <typename SockLenType>
|
1848
|
+
inline int call_setsockopt(SockLenType msghdr::*,
|
1849
|
+
socket_type s, int level, int optname,
|
1850
|
+
const void* optval, std::size_t optlen)
|
1851
|
+
{
|
1852
|
+
return ::setsockopt(s, level, optname,
|
1853
|
+
(const char*)optval, (SockLenType)optlen);
|
1854
|
+
}
|
1855
|
+
|
1856
|
+
int setsockopt(socket_type s, state_type& state, int level, int optname,
|
1857
|
+
const void* optval, std::size_t optlen, asio::error_code& ec)
|
1858
|
+
{
|
1859
|
+
if (s == invalid_socket)
|
1860
|
+
{
|
1861
|
+
ec = asio::error::bad_descriptor;
|
1862
|
+
return socket_error_retval;
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
if (level == custom_socket_option_level && optname == always_fail_option)
|
1866
|
+
{
|
1867
|
+
ec = asio::error::invalid_argument;
|
1868
|
+
return socket_error_retval;
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
if (level == custom_socket_option_level
|
1872
|
+
&& optname == enable_connection_aborted_option)
|
1873
|
+
{
|
1874
|
+
if (optlen != sizeof(int))
|
1875
|
+
{
|
1876
|
+
ec = asio::error::invalid_argument;
|
1877
|
+
return socket_error_retval;
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
if (*static_cast<const int*>(optval))
|
1881
|
+
state |= enable_connection_aborted;
|
1882
|
+
else
|
1883
|
+
state &= ~enable_connection_aborted;
|
1884
|
+
ec.assign(0, ec.category());
|
1885
|
+
return 0;
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
if (level == SOL_SOCKET && optname == SO_LINGER)
|
1889
|
+
state |= user_set_linger;
|
1890
|
+
|
1891
|
+
#if defined(__BORLANDC__)
|
1892
|
+
// Mysteriously, using the getsockopt and setsockopt functions directly with
|
1893
|
+
// Borland C++ results in incorrect values being set and read. The bug can be
|
1894
|
+
// worked around by using function addresses resolved with GetProcAddress.
|
1895
|
+
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
|
1896
|
+
{
|
1897
|
+
typedef int (WSAAPI *sso_t)(SOCKET, int, int, const char*, int);
|
1898
|
+
if (sso_t sso = (sso_t)::GetProcAddress(winsock_module, "setsockopt"))
|
1899
|
+
{
|
1900
|
+
int result = sso(s, level, optname,
|
1901
|
+
reinterpret_cast<const char*>(optval),
|
1902
|
+
static_cast<int>(optlen));
|
1903
|
+
get_last_error(ec, result != 0);
|
1904
|
+
return result;
|
1905
|
+
}
|
1906
|
+
}
|
1907
|
+
ec = asio::error::fault;
|
1908
|
+
return socket_error_retval;
|
1909
|
+
#else // defined(__BORLANDC__)
|
1910
|
+
int result = call_setsockopt(&msghdr::msg_namelen,
|
1911
|
+
s, level, optname, optval, optlen);
|
1912
|
+
get_last_error(ec, result != 0);
|
1913
|
+
if (result == 0)
|
1914
|
+
{
|
1915
|
+
#if defined(__MACH__) && defined(__APPLE__) \
|
1916
|
+
|| defined(__NetBSD__) || defined(__FreeBSD__) \
|
1917
|
+
|| defined(__OpenBSD__) || defined(__QNX__)
|
1918
|
+
// To implement portable behaviour for SO_REUSEADDR with UDP sockets we
|
1919
|
+
// need to also set SO_REUSEPORT on BSD-based platforms.
|
1920
|
+
if ((state & datagram_oriented)
|
1921
|
+
&& level == SOL_SOCKET && optname == SO_REUSEADDR)
|
1922
|
+
{
|
1923
|
+
call_setsockopt(&msghdr::msg_namelen, s,
|
1924
|
+
SOL_SOCKET, SO_REUSEPORT, optval, optlen);
|
1925
|
+
}
|
1926
|
+
#endif
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
return result;
|
1930
|
+
#endif // defined(__BORLANDC__)
|
1931
|
+
}
|
1932
|
+
|
1933
|
+
template <typename SockLenType>
|
1934
|
+
inline int call_getsockopt(SockLenType msghdr::*,
|
1935
|
+
socket_type s, int level, int optname,
|
1936
|
+
void* optval, std::size_t* optlen)
|
1937
|
+
{
|
1938
|
+
SockLenType tmp_optlen = (SockLenType)*optlen;
|
1939
|
+
int result = ::getsockopt(s, level, optname, (char*)optval, &tmp_optlen);
|
1940
|
+
*optlen = (std::size_t)tmp_optlen;
|
1941
|
+
return result;
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
int getsockopt(socket_type s, state_type state, int level, int optname,
|
1945
|
+
void* optval, size_t* optlen, asio::error_code& ec)
|
1946
|
+
{
|
1947
|
+
if (s == invalid_socket)
|
1948
|
+
{
|
1949
|
+
ec = asio::error::bad_descriptor;
|
1950
|
+
return socket_error_retval;
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
if (level == custom_socket_option_level && optname == always_fail_option)
|
1954
|
+
{
|
1955
|
+
ec = asio::error::invalid_argument;
|
1956
|
+
return socket_error_retval;
|
1957
|
+
}
|
1958
|
+
|
1959
|
+
if (level == custom_socket_option_level
|
1960
|
+
&& optname == enable_connection_aborted_option)
|
1961
|
+
{
|
1962
|
+
if (*optlen != sizeof(int))
|
1963
|
+
{
|
1964
|
+
ec = asio::error::invalid_argument;
|
1965
|
+
return socket_error_retval;
|
1966
|
+
}
|
1967
|
+
|
1968
|
+
*static_cast<int*>(optval) = (state & enable_connection_aborted) ? 1 : 0;
|
1969
|
+
ec.assign(0, ec.category());
|
1970
|
+
return 0;
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
#if defined(__BORLANDC__)
|
1974
|
+
// Mysteriously, using the getsockopt and setsockopt functions directly with
|
1975
|
+
// Borland C++ results in incorrect values being set and read. The bug can be
|
1976
|
+
// worked around by using function addresses resolved with GetProcAddress.
|
1977
|
+
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
|
1978
|
+
{
|
1979
|
+
typedef int (WSAAPI *gso_t)(SOCKET, int, int, char*, int*);
|
1980
|
+
if (gso_t gso = (gso_t)::GetProcAddress(winsock_module, "getsockopt"))
|
1981
|
+
{
|
1982
|
+
int tmp_optlen = static_cast<int>(*optlen);
|
1983
|
+
int result = gso(s, level, optname,
|
1984
|
+
reinterpret_cast<char*>(optval), &tmp_optlen);
|
1985
|
+
get_last_error(ec, result != 0);
|
1986
|
+
*optlen = static_cast<size_t>(tmp_optlen);
|
1987
|
+
if (result != 0 && level == IPPROTO_IPV6 && optname == IPV6_V6ONLY
|
1988
|
+
&& ec.value() == WSAENOPROTOOPT && *optlen == sizeof(DWORD))
|
1989
|
+
{
|
1990
|
+
// Dual-stack IPv4/v6 sockets, and the IPV6_V6ONLY socket option, are
|
1991
|
+
// only supported on Windows Vista and later. To simplify program logic
|
1992
|
+
// we will fake success of getting this option and specify that the
|
1993
|
+
// value is non-zero (i.e. true). This corresponds to the behavior of
|
1994
|
+
// IPv6 sockets on Windows platforms pre-Vista.
|
1995
|
+
*static_cast<DWORD*>(optval) = 1;
|
1996
|
+
ec.assign(0, ec.category());
|
1997
|
+
}
|
1998
|
+
return result;
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
ec = asio::error::fault;
|
2002
|
+
return socket_error_retval;
|
2003
|
+
#elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2004
|
+
int result = call_getsockopt(&msghdr::msg_namelen,
|
2005
|
+
s, level, optname, optval, optlen);
|
2006
|
+
get_last_error(ec, result != 0);
|
2007
|
+
if (result != 0 && level == IPPROTO_IPV6 && optname == IPV6_V6ONLY
|
2008
|
+
&& ec.value() == WSAENOPROTOOPT && *optlen == sizeof(DWORD))
|
2009
|
+
{
|
2010
|
+
// Dual-stack IPv4/v6 sockets, and the IPV6_V6ONLY socket option, are only
|
2011
|
+
// supported on Windows Vista and later. To simplify program logic we will
|
2012
|
+
// fake success of getting this option and specify that the value is
|
2013
|
+
// non-zero (i.e. true). This corresponds to the behavior of IPv6 sockets
|
2014
|
+
// on Windows platforms pre-Vista.
|
2015
|
+
*static_cast<DWORD*>(optval) = 1;
|
2016
|
+
ec.assign(0, ec.category());
|
2017
|
+
}
|
2018
|
+
return result;
|
2019
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2020
|
+
int result = call_getsockopt(&msghdr::msg_namelen,
|
2021
|
+
s, level, optname, optval, optlen);
|
2022
|
+
get_last_error(ec, result != 0);
|
2023
|
+
#if defined(__linux__)
|
2024
|
+
if (result == 0 && level == SOL_SOCKET && *optlen == sizeof(int)
|
2025
|
+
&& (optname == SO_SNDBUF || optname == SO_RCVBUF))
|
2026
|
+
{
|
2027
|
+
// On Linux, setting SO_SNDBUF or SO_RCVBUF to N actually causes the kernel
|
2028
|
+
// to set the buffer size to N*2. Linux puts additional stuff into the
|
2029
|
+
// buffers so that only about half is actually available to the application.
|
2030
|
+
// The retrieved value is divided by 2 here to make it appear as though the
|
2031
|
+
// correct value has been set.
|
2032
|
+
*static_cast<int*>(optval) /= 2;
|
2033
|
+
}
|
2034
|
+
#endif // defined(__linux__)
|
2035
|
+
return result;
|
2036
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
template <typename SockLenType>
|
2040
|
+
inline int call_getpeername(SockLenType msghdr::*,
|
2041
|
+
socket_type s, socket_addr_type* addr, std::size_t* addrlen)
|
2042
|
+
{
|
2043
|
+
SockLenType tmp_addrlen = (SockLenType)*addrlen;
|
2044
|
+
int result = ::getpeername(s, addr, &tmp_addrlen);
|
2045
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
2046
|
+
return result;
|
2047
|
+
}
|
2048
|
+
|
2049
|
+
int getpeername(socket_type s, socket_addr_type* addr,
|
2050
|
+
std::size_t* addrlen, bool cached, asio::error_code& ec)
|
2051
|
+
{
|
2052
|
+
if (s == invalid_socket)
|
2053
|
+
{
|
2054
|
+
ec = asio::error::bad_descriptor;
|
2055
|
+
return socket_error_retval;
|
2056
|
+
}
|
2057
|
+
|
2058
|
+
#if defined(ASIO_WINDOWS) && !defined(ASIO_WINDOWS_APP) \
|
2059
|
+
|| defined(__CYGWIN__)
|
2060
|
+
if (cached)
|
2061
|
+
{
|
2062
|
+
// Check if socket is still connected.
|
2063
|
+
DWORD connect_time = 0;
|
2064
|
+
size_t connect_time_len = sizeof(connect_time);
|
2065
|
+
if (socket_ops::getsockopt(s, 0, SOL_SOCKET, SO_CONNECT_TIME,
|
2066
|
+
&connect_time, &connect_time_len, ec) == socket_error_retval)
|
2067
|
+
{
|
2068
|
+
return socket_error_retval;
|
2069
|
+
}
|
2070
|
+
if (connect_time == 0xFFFFFFFF)
|
2071
|
+
{
|
2072
|
+
ec = asio::error::not_connected;
|
2073
|
+
return socket_error_retval;
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
// The cached value is still valid.
|
2077
|
+
ec.assign(0, ec.category());
|
2078
|
+
return 0;
|
2079
|
+
}
|
2080
|
+
#else // defined(ASIO_WINDOWS) && !defined(ASIO_WINDOWS_APP)
|
2081
|
+
// || defined(__CYGWIN__)
|
2082
|
+
(void)cached;
|
2083
|
+
#endif // defined(ASIO_WINDOWS) && !defined(ASIO_WINDOWS_APP)
|
2084
|
+
// || defined(__CYGWIN__)
|
2085
|
+
|
2086
|
+
int result = call_getpeername(&msghdr::msg_namelen, s, addr, addrlen);
|
2087
|
+
get_last_error(ec, result != 0);
|
2088
|
+
return result;
|
2089
|
+
}
|
2090
|
+
|
2091
|
+
template <typename SockLenType>
|
2092
|
+
inline int call_getsockname(SockLenType msghdr::*,
|
2093
|
+
socket_type s, socket_addr_type* addr, std::size_t* addrlen)
|
2094
|
+
{
|
2095
|
+
SockLenType tmp_addrlen = (SockLenType)*addrlen;
|
2096
|
+
int result = ::getsockname(s, addr, &tmp_addrlen);
|
2097
|
+
*addrlen = (std::size_t)tmp_addrlen;
|
2098
|
+
return result;
|
2099
|
+
}
|
2100
|
+
|
2101
|
+
int getsockname(socket_type s, socket_addr_type* addr,
|
2102
|
+
std::size_t* addrlen, asio::error_code& ec)
|
2103
|
+
{
|
2104
|
+
if (s == invalid_socket)
|
2105
|
+
{
|
2106
|
+
ec = asio::error::bad_descriptor;
|
2107
|
+
return socket_error_retval;
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
int result = call_getsockname(&msghdr::msg_namelen, s, addr, addrlen);
|
2111
|
+
get_last_error(ec, result != 0);
|
2112
|
+
return result;
|
2113
|
+
}
|
2114
|
+
|
2115
|
+
int ioctl(socket_type s, state_type& state, int cmd,
|
2116
|
+
ioctl_arg_type* arg, asio::error_code& ec)
|
2117
|
+
{
|
2118
|
+
if (s == invalid_socket)
|
2119
|
+
{
|
2120
|
+
ec = asio::error::bad_descriptor;
|
2121
|
+
return socket_error_retval;
|
2122
|
+
}
|
2123
|
+
|
2124
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2125
|
+
int result = ::ioctlsocket(s, cmd, arg);
|
2126
|
+
#elif defined(__MACH__) && defined(__APPLE__) \
|
2127
|
+
|| defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
2128
|
+
int result = ::ioctl(s, static_cast<unsigned int>(cmd), arg);
|
2129
|
+
#else
|
2130
|
+
int result = ::ioctl(s, cmd, arg);
|
2131
|
+
#endif
|
2132
|
+
get_last_error(ec, result < 0);
|
2133
|
+
if (result >= 0)
|
2134
|
+
{
|
2135
|
+
// When updating the non-blocking mode we always perform the ioctl syscall,
|
2136
|
+
// even if the flags would otherwise indicate that the socket is already in
|
2137
|
+
// the correct state. This ensures that the underlying socket is put into
|
2138
|
+
// the state that has been requested by the user. If the ioctl syscall was
|
2139
|
+
// successful then we need to update the flags to match.
|
2140
|
+
if (cmd == static_cast<int>(FIONBIO))
|
2141
|
+
{
|
2142
|
+
if (*arg)
|
2143
|
+
{
|
2144
|
+
state |= user_set_non_blocking;
|
2145
|
+
}
|
2146
|
+
else
|
2147
|
+
{
|
2148
|
+
// Clearing the non-blocking mode always overrides any internally-set
|
2149
|
+
// non-blocking flag. Any subsequent asynchronous operations will need
|
2150
|
+
// to re-enable non-blocking I/O.
|
2151
|
+
state &= ~(user_set_non_blocking | internal_non_blocking);
|
2152
|
+
}
|
2153
|
+
}
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
return result;
|
2157
|
+
}
|
2158
|
+
|
2159
|
+
int select(int nfds, fd_set* readfds, fd_set* writefds,
|
2160
|
+
fd_set* exceptfds, timeval* timeout, asio::error_code& ec)
|
2161
|
+
{
|
2162
|
+
#if defined(__EMSCRIPTEN__)
|
2163
|
+
exceptfds = 0;
|
2164
|
+
#endif // defined(__EMSCRIPTEN__)
|
2165
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2166
|
+
if (!readfds && !writefds && !exceptfds && timeout)
|
2167
|
+
{
|
2168
|
+
DWORD milliseconds = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
2169
|
+
if (milliseconds == 0)
|
2170
|
+
milliseconds = 1; // Force context switch.
|
2171
|
+
::Sleep(milliseconds);
|
2172
|
+
ec.assign(0, ec.category());
|
2173
|
+
return 0;
|
2174
|
+
}
|
2175
|
+
|
2176
|
+
// The select() call allows timeout values measured in microseconds, but the
|
2177
|
+
// system clock (as wrapped by boost::posix_time::microsec_clock) typically
|
2178
|
+
// has a resolution of 10 milliseconds. This can lead to a spinning select
|
2179
|
+
// reactor, meaning increased CPU usage, when waiting for the earliest
|
2180
|
+
// scheduled timeout if it's less than 10 milliseconds away. To avoid a tight
|
2181
|
+
// spin we'll use a minimum timeout of 1 millisecond.
|
2182
|
+
if (timeout && timeout->tv_sec == 0
|
2183
|
+
&& timeout->tv_usec > 0 && timeout->tv_usec < 1000)
|
2184
|
+
timeout->tv_usec = 1000;
|
2185
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2186
|
+
|
2187
|
+
#if defined(__hpux) && defined(__SELECT)
|
2188
|
+
timespec ts;
|
2189
|
+
ts.tv_sec = timeout ? timeout->tv_sec : 0;
|
2190
|
+
ts.tv_nsec = timeout ? timeout->tv_usec * 1000 : 0;
|
2191
|
+
int result = ::pselect(nfds, readfds,
|
2192
|
+
writefds, exceptfds, timeout ? &ts : 0, 0);
|
2193
|
+
#else
|
2194
|
+
int result = ::select(nfds, readfds, writefds, exceptfds, timeout);
|
2195
|
+
#endif
|
2196
|
+
get_last_error(ec, result < 0);
|
2197
|
+
return result;
|
2198
|
+
}
|
2199
|
+
|
2200
|
+
int poll_read(socket_type s, state_type state,
|
2201
|
+
int msec, asio::error_code& ec)
|
2202
|
+
{
|
2203
|
+
if (s == invalid_socket)
|
2204
|
+
{
|
2205
|
+
ec = asio::error::bad_descriptor;
|
2206
|
+
return socket_error_retval;
|
2207
|
+
}
|
2208
|
+
|
2209
|
+
#if defined(ASIO_WINDOWS) \
|
2210
|
+
|| defined(__CYGWIN__) \
|
2211
|
+
|| defined(__SYMBIAN32__)
|
2212
|
+
fd_set fds;
|
2213
|
+
FD_ZERO(&fds);
|
2214
|
+
FD_SET(s, &fds);
|
2215
|
+
timeval timeout_obj;
|
2216
|
+
timeval* timeout;
|
2217
|
+
if (state & user_set_non_blocking)
|
2218
|
+
{
|
2219
|
+
timeout_obj.tv_sec = 0;
|
2220
|
+
timeout_obj.tv_usec = 0;
|
2221
|
+
timeout = &timeout_obj;
|
2222
|
+
}
|
2223
|
+
else if (msec >= 0)
|
2224
|
+
{
|
2225
|
+
timeout_obj.tv_sec = msec / 1000;
|
2226
|
+
timeout_obj.tv_usec = (msec % 1000) * 1000;
|
2227
|
+
timeout = &timeout_obj;
|
2228
|
+
}
|
2229
|
+
else
|
2230
|
+
timeout = 0;
|
2231
|
+
int result = ::select(s + 1, &fds, 0, 0, timeout);
|
2232
|
+
get_last_error(ec, result < 0);
|
2233
|
+
#else // defined(ASIO_WINDOWS)
|
2234
|
+
// || defined(__CYGWIN__)
|
2235
|
+
// || defined(__SYMBIAN32__)
|
2236
|
+
pollfd fds;
|
2237
|
+
fds.fd = s;
|
2238
|
+
fds.events = POLLIN;
|
2239
|
+
fds.revents = 0;
|
2240
|
+
int timeout = (state & user_set_non_blocking) ? 0 : msec;
|
2241
|
+
int result = ::poll(&fds, 1, timeout);
|
2242
|
+
get_last_error(ec, result < 0);
|
2243
|
+
#endif // defined(ASIO_WINDOWS)
|
2244
|
+
// || defined(__CYGWIN__)
|
2245
|
+
// || defined(__SYMBIAN32__)
|
2246
|
+
if (result == 0)
|
2247
|
+
if (state & user_set_non_blocking)
|
2248
|
+
ec = asio::error::would_block;
|
2249
|
+
return result;
|
2250
|
+
}
|
2251
|
+
|
2252
|
+
int poll_write(socket_type s, state_type state,
|
2253
|
+
int msec, asio::error_code& ec)
|
2254
|
+
{
|
2255
|
+
if (s == invalid_socket)
|
2256
|
+
{
|
2257
|
+
ec = asio::error::bad_descriptor;
|
2258
|
+
return socket_error_retval;
|
2259
|
+
}
|
2260
|
+
|
2261
|
+
#if defined(ASIO_WINDOWS) \
|
2262
|
+
|| defined(__CYGWIN__) \
|
2263
|
+
|| defined(__SYMBIAN32__)
|
2264
|
+
fd_set fds;
|
2265
|
+
FD_ZERO(&fds);
|
2266
|
+
FD_SET(s, &fds);
|
2267
|
+
timeval timeout_obj;
|
2268
|
+
timeval* timeout;
|
2269
|
+
if (state & user_set_non_blocking)
|
2270
|
+
{
|
2271
|
+
timeout_obj.tv_sec = 0;
|
2272
|
+
timeout_obj.tv_usec = 0;
|
2273
|
+
timeout = &timeout_obj;
|
2274
|
+
}
|
2275
|
+
else if (msec >= 0)
|
2276
|
+
{
|
2277
|
+
timeout_obj.tv_sec = msec / 1000;
|
2278
|
+
timeout_obj.tv_usec = (msec % 1000) * 1000;
|
2279
|
+
timeout = &timeout_obj;
|
2280
|
+
}
|
2281
|
+
else
|
2282
|
+
timeout = 0;
|
2283
|
+
int result = ::select(s + 1, 0, &fds, 0, timeout);
|
2284
|
+
get_last_error(ec, result < 0);
|
2285
|
+
#else // defined(ASIO_WINDOWS)
|
2286
|
+
// || defined(__CYGWIN__)
|
2287
|
+
// || defined(__SYMBIAN32__)
|
2288
|
+
pollfd fds;
|
2289
|
+
fds.fd = s;
|
2290
|
+
fds.events = POLLOUT;
|
2291
|
+
fds.revents = 0;
|
2292
|
+
int timeout = (state & user_set_non_blocking) ? 0 : msec;
|
2293
|
+
int result = ::poll(&fds, 1, timeout);
|
2294
|
+
get_last_error(ec, result < 0);
|
2295
|
+
#endif // defined(ASIO_WINDOWS)
|
2296
|
+
// || defined(__CYGWIN__)
|
2297
|
+
// || defined(__SYMBIAN32__)
|
2298
|
+
if (result == 0)
|
2299
|
+
if (state & user_set_non_blocking)
|
2300
|
+
ec = asio::error::would_block;
|
2301
|
+
return result;
|
2302
|
+
}
|
2303
|
+
|
2304
|
+
int poll_error(socket_type s, state_type state,
|
2305
|
+
int msec, asio::error_code& ec)
|
2306
|
+
{
|
2307
|
+
if (s == invalid_socket)
|
2308
|
+
{
|
2309
|
+
ec = asio::error::bad_descriptor;
|
2310
|
+
return socket_error_retval;
|
2311
|
+
}
|
2312
|
+
|
2313
|
+
#if defined(ASIO_WINDOWS) \
|
2314
|
+
|| defined(__CYGWIN__) \
|
2315
|
+
|| defined(__SYMBIAN32__)
|
2316
|
+
fd_set fds;
|
2317
|
+
FD_ZERO(&fds);
|
2318
|
+
FD_SET(s, &fds);
|
2319
|
+
timeval timeout_obj;
|
2320
|
+
timeval* timeout;
|
2321
|
+
if (state & user_set_non_blocking)
|
2322
|
+
{
|
2323
|
+
timeout_obj.tv_sec = 0;
|
2324
|
+
timeout_obj.tv_usec = 0;
|
2325
|
+
timeout = &timeout_obj;
|
2326
|
+
}
|
2327
|
+
else if (msec >= 0)
|
2328
|
+
{
|
2329
|
+
timeout_obj.tv_sec = msec / 1000;
|
2330
|
+
timeout_obj.tv_usec = (msec % 1000) * 1000;
|
2331
|
+
timeout = &timeout_obj;
|
2332
|
+
}
|
2333
|
+
else
|
2334
|
+
timeout = 0;
|
2335
|
+
int result = ::select(s + 1, 0, 0, &fds, timeout);
|
2336
|
+
get_last_error(ec, result < 0);
|
2337
|
+
#else // defined(ASIO_WINDOWS)
|
2338
|
+
// || defined(__CYGWIN__)
|
2339
|
+
// || defined(__SYMBIAN32__)
|
2340
|
+
pollfd fds;
|
2341
|
+
fds.fd = s;
|
2342
|
+
fds.events = POLLPRI | POLLERR | POLLHUP;
|
2343
|
+
fds.revents = 0;
|
2344
|
+
int timeout = (state & user_set_non_blocking) ? 0 : msec;
|
2345
|
+
int result = ::poll(&fds, 1, timeout);
|
2346
|
+
get_last_error(ec, result < 0);
|
2347
|
+
#endif // defined(ASIO_WINDOWS)
|
2348
|
+
// || defined(__CYGWIN__)
|
2349
|
+
// || defined(__SYMBIAN32__)
|
2350
|
+
if (result == 0)
|
2351
|
+
if (state & user_set_non_blocking)
|
2352
|
+
ec = asio::error::would_block;
|
2353
|
+
return result;
|
2354
|
+
}
|
2355
|
+
|
2356
|
+
int poll_connect(socket_type s, int msec, asio::error_code& ec)
|
2357
|
+
{
|
2358
|
+
if (s == invalid_socket)
|
2359
|
+
{
|
2360
|
+
ec = asio::error::bad_descriptor;
|
2361
|
+
return socket_error_retval;
|
2362
|
+
}
|
2363
|
+
|
2364
|
+
#if defined(ASIO_WINDOWS) \
|
2365
|
+
|| defined(__CYGWIN__) \
|
2366
|
+
|| defined(__SYMBIAN32__)
|
2367
|
+
fd_set write_fds;
|
2368
|
+
FD_ZERO(&write_fds);
|
2369
|
+
FD_SET(s, &write_fds);
|
2370
|
+
fd_set except_fds;
|
2371
|
+
FD_ZERO(&except_fds);
|
2372
|
+
FD_SET(s, &except_fds);
|
2373
|
+
timeval timeout_obj;
|
2374
|
+
timeval* timeout;
|
2375
|
+
if (msec >= 0)
|
2376
|
+
{
|
2377
|
+
timeout_obj.tv_sec = msec / 1000;
|
2378
|
+
timeout_obj.tv_usec = (msec % 1000) * 1000;
|
2379
|
+
timeout = &timeout_obj;
|
2380
|
+
}
|
2381
|
+
else
|
2382
|
+
timeout = 0;
|
2383
|
+
int result = ::select(s + 1, 0, &write_fds, &except_fds, timeout);
|
2384
|
+
get_last_error(ec, result < 0);
|
2385
|
+
return result;
|
2386
|
+
#else // defined(ASIO_WINDOWS)
|
2387
|
+
// || defined(__CYGWIN__)
|
2388
|
+
// || defined(__SYMBIAN32__)
|
2389
|
+
pollfd fds;
|
2390
|
+
fds.fd = s;
|
2391
|
+
fds.events = POLLOUT;
|
2392
|
+
fds.revents = 0;
|
2393
|
+
int result = ::poll(&fds, 1, msec);
|
2394
|
+
get_last_error(ec, result < 0);
|
2395
|
+
return result;
|
2396
|
+
#endif // defined(ASIO_WINDOWS)
|
2397
|
+
// || defined(__CYGWIN__)
|
2398
|
+
// || defined(__SYMBIAN32__)
|
2399
|
+
}
|
2400
|
+
|
2401
|
+
#endif // !defined(ASIO_WINDOWS_RUNTIME)
|
2402
|
+
|
2403
|
+
const char* inet_ntop(int af, const void* src, char* dest, size_t length,
|
2404
|
+
unsigned long scope_id, asio::error_code& ec)
|
2405
|
+
{
|
2406
|
+
clear_last_error();
|
2407
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
2408
|
+
using namespace std; // For sprintf.
|
2409
|
+
const unsigned char* bytes = static_cast<const unsigned char*>(src);
|
2410
|
+
if (af == ASIO_OS_DEF(AF_INET))
|
2411
|
+
{
|
2412
|
+
sprintf_s(dest, length, "%u.%u.%u.%u",
|
2413
|
+
bytes[0], bytes[1], bytes[2], bytes[3]);
|
2414
|
+
return dest;
|
2415
|
+
}
|
2416
|
+
else if (af == ASIO_OS_DEF(AF_INET6))
|
2417
|
+
{
|
2418
|
+
size_t n = 0, b = 0, z = 0;
|
2419
|
+
while (n < length && b < 16)
|
2420
|
+
{
|
2421
|
+
if (bytes[b] == 0 && bytes[b + 1] == 0 && z == 0)
|
2422
|
+
{
|
2423
|
+
do b += 2; while (b < 16 && bytes[b] == 0 && bytes[b + 1] == 0);
|
2424
|
+
n += sprintf_s(dest + n, length - n, ":%s", b < 16 ? "" : ":"), ++z;
|
2425
|
+
}
|
2426
|
+
else
|
2427
|
+
{
|
2428
|
+
n += sprintf_s(dest + n, length - n, "%s%x", b ? ":" : "",
|
2429
|
+
(static_cast<u_long_type>(bytes[b]) << 8) | bytes[b + 1]);
|
2430
|
+
b += 2;
|
2431
|
+
}
|
2432
|
+
}
|
2433
|
+
if (scope_id)
|
2434
|
+
n += sprintf_s(dest + n, length - n, "%%%lu", scope_id);
|
2435
|
+
return dest;
|
2436
|
+
}
|
2437
|
+
else
|
2438
|
+
{
|
2439
|
+
ec = asio::error::address_family_not_supported;
|
2440
|
+
return 0;
|
2441
|
+
}
|
2442
|
+
#elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2443
|
+
using namespace std; // For memcpy.
|
2444
|
+
|
2445
|
+
if (af != ASIO_OS_DEF(AF_INET) && af != ASIO_OS_DEF(AF_INET6))
|
2446
|
+
{
|
2447
|
+
ec = asio::error::address_family_not_supported;
|
2448
|
+
return 0;
|
2449
|
+
}
|
2450
|
+
|
2451
|
+
union
|
2452
|
+
{
|
2453
|
+
socket_addr_type base;
|
2454
|
+
sockaddr_storage_type storage;
|
2455
|
+
sockaddr_in4_type v4;
|
2456
|
+
sockaddr_in6_type v6;
|
2457
|
+
} address;
|
2458
|
+
DWORD address_length;
|
2459
|
+
if (af == ASIO_OS_DEF(AF_INET))
|
2460
|
+
{
|
2461
|
+
address_length = sizeof(sockaddr_in4_type);
|
2462
|
+
address.v4.sin_family = ASIO_OS_DEF(AF_INET);
|
2463
|
+
address.v4.sin_port = 0;
|
2464
|
+
memcpy(&address.v4.sin_addr, src, sizeof(in4_addr_type));
|
2465
|
+
}
|
2466
|
+
else // AF_INET6
|
2467
|
+
{
|
2468
|
+
address_length = sizeof(sockaddr_in6_type);
|
2469
|
+
address.v6.sin6_family = ASIO_OS_DEF(AF_INET6);
|
2470
|
+
address.v6.sin6_port = 0;
|
2471
|
+
address.v6.sin6_flowinfo = 0;
|
2472
|
+
address.v6.sin6_scope_id = scope_id;
|
2473
|
+
memcpy(&address.v6.sin6_addr, src, sizeof(in6_addr_type));
|
2474
|
+
}
|
2475
|
+
|
2476
|
+
DWORD string_length = static_cast<DWORD>(length);
|
2477
|
+
#if defined(BOOST_NO_ANSI_APIS) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
|
2478
|
+
LPWSTR string_buffer = (LPWSTR)_alloca(length * sizeof(WCHAR));
|
2479
|
+
int result = ::WSAAddressToStringW(&address.base,
|
2480
|
+
address_length, 0, string_buffer, &string_length);
|
2481
|
+
get_last_error(ec, true);
|
2482
|
+
::WideCharToMultiByte(CP_ACP, 0, string_buffer, -1,
|
2483
|
+
dest, static_cast<int>(length), 0, 0);
|
2484
|
+
#else
|
2485
|
+
int result = ::WSAAddressToStringA(&address.base,
|
2486
|
+
address_length, 0, dest, &string_length);
|
2487
|
+
get_last_error(ec, true);
|
2488
|
+
#endif
|
2489
|
+
|
2490
|
+
// Windows may set error code on success.
|
2491
|
+
if (result != socket_error_retval)
|
2492
|
+
ec.assign(0, ec.category());
|
2493
|
+
|
2494
|
+
// Windows may not set an error code on failure.
|
2495
|
+
else if (result == socket_error_retval && !ec)
|
2496
|
+
ec = asio::error::invalid_argument;
|
2497
|
+
|
2498
|
+
return result == socket_error_retval ? 0 : dest;
|
2499
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2500
|
+
const char* result = ::inet_ntop(af, src, dest, static_cast<int>(length));
|
2501
|
+
get_last_error(ec, true);
|
2502
|
+
if (result == 0 && !ec)
|
2503
|
+
ec = asio::error::invalid_argument;
|
2504
|
+
if (result != 0 && af == ASIO_OS_DEF(AF_INET6) && scope_id != 0)
|
2505
|
+
{
|
2506
|
+
using namespace std; // For strcat and sprintf.
|
2507
|
+
char if_name[(IF_NAMESIZE > 21 ? IF_NAMESIZE : 21) + 1] = "%";
|
2508
|
+
const in6_addr_type* ipv6_address = static_cast<const in6_addr_type*>(src);
|
2509
|
+
bool is_link_local = ((ipv6_address->s6_addr[0] == 0xfe)
|
2510
|
+
&& ((ipv6_address->s6_addr[1] & 0xc0) == 0x80));
|
2511
|
+
bool is_multicast_link_local = ((ipv6_address->s6_addr[0] == 0xff)
|
2512
|
+
&& ((ipv6_address->s6_addr[1] & 0x0f) == 0x02));
|
2513
|
+
if ((!is_link_local && !is_multicast_link_local)
|
2514
|
+
|| if_indextoname(static_cast<unsigned>(scope_id), if_name + 1) == 0)
|
2515
|
+
sprintf(if_name + 1, "%lu", scope_id);
|
2516
|
+
strcat(dest, if_name);
|
2517
|
+
}
|
2518
|
+
return result;
|
2519
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
int inet_pton(int af, const char* src, void* dest,
|
2523
|
+
unsigned long* scope_id, asio::error_code& ec)
|
2524
|
+
{
|
2525
|
+
clear_last_error();
|
2526
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
2527
|
+
using namespace std; // For sscanf.
|
2528
|
+
unsigned char* bytes = static_cast<unsigned char*>(dest);
|
2529
|
+
if (af == ASIO_OS_DEF(AF_INET))
|
2530
|
+
{
|
2531
|
+
unsigned int b0, b1, b2, b3;
|
2532
|
+
if (sscanf_s(src, "%u.%u.%u.%u", &b0, &b1, &b2, &b3) != 4)
|
2533
|
+
{
|
2534
|
+
ec = asio::error::invalid_argument;
|
2535
|
+
return -1;
|
2536
|
+
}
|
2537
|
+
if (b0 > 255 || b1 > 255 || b2 > 255 || b3 > 255)
|
2538
|
+
{
|
2539
|
+
ec = asio::error::invalid_argument;
|
2540
|
+
return -1;
|
2541
|
+
}
|
2542
|
+
bytes[0] = static_cast<unsigned char>(b0);
|
2543
|
+
bytes[1] = static_cast<unsigned char>(b1);
|
2544
|
+
bytes[2] = static_cast<unsigned char>(b2);
|
2545
|
+
bytes[3] = static_cast<unsigned char>(b3);
|
2546
|
+
ec.assign(), ec.category());
|
2547
|
+
return 1;
|
2548
|
+
}
|
2549
|
+
else if (af == ASIO_OS_DEF(AF_INET6))
|
2550
|
+
{
|
2551
|
+
unsigned char* bytes = static_cast<unsigned char*>(dest);
|
2552
|
+
std::memset(bytes, 0, 16);
|
2553
|
+
unsigned char back_bytes[16] = { 0 };
|
2554
|
+
int num_front_bytes = 0, num_back_bytes = 0;
|
2555
|
+
const char* p = src;
|
2556
|
+
|
2557
|
+
enum { fword, fcolon, bword, scope, done } state = fword;
|
2558
|
+
unsigned long current_word = 0;
|
2559
|
+
while (state != done)
|
2560
|
+
{
|
2561
|
+
if (current_word > 0xFFFF)
|
2562
|
+
{
|
2563
|
+
ec = asio::error::invalid_argument;
|
2564
|
+
return -1;
|
2565
|
+
}
|
2566
|
+
|
2567
|
+
switch (state)
|
2568
|
+
{
|
2569
|
+
case fword:
|
2570
|
+
if (*p >= '0' && *p <= '9')
|
2571
|
+
current_word = current_word * 16 + *p++ - '0';
|
2572
|
+
else if (*p >= 'a' && *p <= 'f')
|
2573
|
+
current_word = current_word * 16 + *p++ - 'a' + 10;
|
2574
|
+
else if (*p >= 'A' && *p <= 'F')
|
2575
|
+
current_word = current_word * 16 + *p++ - 'A' + 10;
|
2576
|
+
else
|
2577
|
+
{
|
2578
|
+
if (num_front_bytes == 16)
|
2579
|
+
{
|
2580
|
+
ec = asio::error::invalid_argument;
|
2581
|
+
return -1;
|
2582
|
+
}
|
2583
|
+
|
2584
|
+
bytes[num_front_bytes++] = (current_word >> 8) & 0xFF;
|
2585
|
+
bytes[num_front_bytes++] = current_word & 0xFF;
|
2586
|
+
current_word = 0;
|
2587
|
+
|
2588
|
+
if (*p == ':')
|
2589
|
+
state = fcolon, ++p;
|
2590
|
+
else if (*p == '%')
|
2591
|
+
state = scope, ++p;
|
2592
|
+
else if (*p == 0)
|
2593
|
+
state = done;
|
2594
|
+
else
|
2595
|
+
{
|
2596
|
+
ec = asio::error::invalid_argument;
|
2597
|
+
return -1;
|
2598
|
+
}
|
2599
|
+
}
|
2600
|
+
break;
|
2601
|
+
|
2602
|
+
case fcolon:
|
2603
|
+
if (*p == ':')
|
2604
|
+
state = bword, ++p;
|
2605
|
+
else
|
2606
|
+
state = fword;
|
2607
|
+
break;
|
2608
|
+
|
2609
|
+
case bword:
|
2610
|
+
if (*p >= '0' && *p <= '9')
|
2611
|
+
current_word = current_word * 16 + *p++ - '0';
|
2612
|
+
else if (*p >= 'a' && *p <= 'f')
|
2613
|
+
current_word = current_word * 16 + *p++ - 'a' + 10;
|
2614
|
+
else if (*p >= 'A' && *p <= 'F')
|
2615
|
+
current_word = current_word * 16 + *p++ - 'A' + 10;
|
2616
|
+
else
|
2617
|
+
{
|
2618
|
+
if (num_front_bytes + num_back_bytes == 16)
|
2619
|
+
{
|
2620
|
+
ec = asio::error::invalid_argument;
|
2621
|
+
return -1;
|
2622
|
+
}
|
2623
|
+
|
2624
|
+
back_bytes[num_back_bytes++] = (current_word >> 8) & 0xFF;
|
2625
|
+
back_bytes[num_back_bytes++] = current_word & 0xFF;
|
2626
|
+
current_word = 0;
|
2627
|
+
|
2628
|
+
if (*p == ':')
|
2629
|
+
state = bword, ++p;
|
2630
|
+
else if (*p == '%')
|
2631
|
+
state = scope, ++p;
|
2632
|
+
else if (*p == 0)
|
2633
|
+
state = done;
|
2634
|
+
else
|
2635
|
+
{
|
2636
|
+
ec = asio::error::invalid_argument;
|
2637
|
+
return -1;
|
2638
|
+
}
|
2639
|
+
}
|
2640
|
+
break;
|
2641
|
+
|
2642
|
+
case scope:
|
2643
|
+
if (*p >= '0' && *p <= '9')
|
2644
|
+
current_word = current_word * 10 + *p++ - '0';
|
2645
|
+
else if (*p == 0)
|
2646
|
+
*scope_id = current_word, state = done;
|
2647
|
+
else
|
2648
|
+
{
|
2649
|
+
ec = asio::error::invalid_argument;
|
2650
|
+
return -1;
|
2651
|
+
}
|
2652
|
+
break;
|
2653
|
+
|
2654
|
+
default:
|
2655
|
+
break;
|
2656
|
+
}
|
2657
|
+
}
|
2658
|
+
|
2659
|
+
for (int i = 0; i < num_back_bytes; ++i)
|
2660
|
+
bytes[16 - num_back_bytes + i] = back_bytes[i];
|
2661
|
+
|
2662
|
+
ec.assign(0, ec.category());
|
2663
|
+
return 1;
|
2664
|
+
}
|
2665
|
+
else
|
2666
|
+
{
|
2667
|
+
ec = asio::error::address_family_not_supported;
|
2668
|
+
return -1;
|
2669
|
+
}
|
2670
|
+
#elif defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2671
|
+
using namespace std; // For memcpy and strcmp.
|
2672
|
+
|
2673
|
+
if (af != ASIO_OS_DEF(AF_INET) && af != ASIO_OS_DEF(AF_INET6))
|
2674
|
+
{
|
2675
|
+
ec = asio::error::address_family_not_supported;
|
2676
|
+
return -1;
|
2677
|
+
}
|
2678
|
+
|
2679
|
+
union
|
2680
|
+
{
|
2681
|
+
socket_addr_type base;
|
2682
|
+
sockaddr_storage_type storage;
|
2683
|
+
sockaddr_in4_type v4;
|
2684
|
+
sockaddr_in6_type v6;
|
2685
|
+
} address;
|
2686
|
+
int address_length = sizeof(sockaddr_storage_type);
|
2687
|
+
#if defined(BOOST_NO_ANSI_APIS) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
|
2688
|
+
int num_wide_chars = static_cast<int>(strlen(src)) + 1;
|
2689
|
+
LPWSTR wide_buffer = (LPWSTR)_alloca(num_wide_chars * sizeof(WCHAR));
|
2690
|
+
::MultiByteToWideChar(CP_ACP, 0, src, -1, wide_buffer, num_wide_chars);
|
2691
|
+
int result = ::WSAStringToAddressW(wide_buffer,
|
2692
|
+
af, 0, &address.base, &address_length);
|
2693
|
+
get_last_error(ec, true);
|
2694
|
+
#else
|
2695
|
+
int result = ::WSAStringToAddressA(const_cast<char*>(src),
|
2696
|
+
af, 0, &address.base, &address_length);
|
2697
|
+
get_last_error(ec, true);
|
2698
|
+
#endif
|
2699
|
+
|
2700
|
+
if (af == ASIO_OS_DEF(AF_INET))
|
2701
|
+
{
|
2702
|
+
if (result != socket_error_retval)
|
2703
|
+
{
|
2704
|
+
memcpy(dest, &address.v4.sin_addr, sizeof(in4_addr_type));
|
2705
|
+
ec.assign(0, ec.category());
|
2706
|
+
}
|
2707
|
+
else if (strcmp(src, "255.255.255.255") == 0)
|
2708
|
+
{
|
2709
|
+
static_cast<in4_addr_type*>(dest)->s_addr = INADDR_NONE;
|
2710
|
+
ec.assign(0, ec.category());
|
2711
|
+
}
|
2712
|
+
}
|
2713
|
+
else // AF_INET6
|
2714
|
+
{
|
2715
|
+
if (result != socket_error_retval)
|
2716
|
+
{
|
2717
|
+
memcpy(dest, &address.v6.sin6_addr, sizeof(in6_addr_type));
|
2718
|
+
if (scope_id)
|
2719
|
+
*scope_id = address.v6.sin6_scope_id;
|
2720
|
+
ec.assign(0, ec.category());
|
2721
|
+
}
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
// Windows may not set an error code on failure.
|
2725
|
+
if (result == socket_error_retval && !ec)
|
2726
|
+
ec = asio::error::invalid_argument;
|
2727
|
+
|
2728
|
+
if (result != socket_error_retval)
|
2729
|
+
ec.assign(0, ec.category());
|
2730
|
+
|
2731
|
+
return result == socket_error_retval ? -1 : 1;
|
2732
|
+
#else // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2733
|
+
using namespace std; // For strchr, memcpy and atoi.
|
2734
|
+
|
2735
|
+
// On some platforms, inet_pton fails if an address string contains a scope
|
2736
|
+
// id. Detect and remove the scope id before passing the string to inet_pton.
|
2737
|
+
const bool is_v6 = (af == ASIO_OS_DEF(AF_INET6));
|
2738
|
+
const char* if_name = is_v6 ? strchr(src, '%') : 0;
|
2739
|
+
char src_buf[max_addr_v6_str_len + 1];
|
2740
|
+
const char* src_ptr = src;
|
2741
|
+
if (if_name != 0)
|
2742
|
+
{
|
2743
|
+
if (if_name - src > max_addr_v6_str_len)
|
2744
|
+
{
|
2745
|
+
ec = asio::error::invalid_argument;
|
2746
|
+
return 0;
|
2747
|
+
}
|
2748
|
+
memcpy(src_buf, src, if_name - src);
|
2749
|
+
src_buf[if_name - src] = 0;
|
2750
|
+
src_ptr = src_buf;
|
2751
|
+
}
|
2752
|
+
|
2753
|
+
int result = ::inet_pton(af, src_ptr, dest);
|
2754
|
+
get_last_error(ec, true);
|
2755
|
+
if (result <= 0 && !ec)
|
2756
|
+
ec = asio::error::invalid_argument;
|
2757
|
+
if (result > 0 && is_v6 && scope_id)
|
2758
|
+
{
|
2759
|
+
using namespace std; // For strchr and atoi.
|
2760
|
+
*scope_id = 0;
|
2761
|
+
if (if_name != 0)
|
2762
|
+
{
|
2763
|
+
in6_addr_type* ipv6_address = static_cast<in6_addr_type*>(dest);
|
2764
|
+
bool is_link_local = ((ipv6_address->s6_addr[0] == 0xfe)
|
2765
|
+
&& ((ipv6_address->s6_addr[1] & 0xc0) == 0x80));
|
2766
|
+
bool is_multicast_link_local = ((ipv6_address->s6_addr[0] == 0xff)
|
2767
|
+
&& ((ipv6_address->s6_addr[1] & 0x0f) == 0x02));
|
2768
|
+
if (is_link_local || is_multicast_link_local)
|
2769
|
+
*scope_id = if_nametoindex(if_name + 1);
|
2770
|
+
if (*scope_id == 0)
|
2771
|
+
*scope_id = atoi(if_name + 1);
|
2772
|
+
}
|
2773
|
+
}
|
2774
|
+
return result;
|
2775
|
+
#endif // defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2776
|
+
}
|
2777
|
+
|
2778
|
+
int gethostname(char* name, int namelen, asio::error_code& ec)
|
2779
|
+
{
|
2780
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
2781
|
+
try
|
2782
|
+
{
|
2783
|
+
using namespace Windows::Foundation::Collections;
|
2784
|
+
using namespace Windows::Networking;
|
2785
|
+
using namespace Windows::Networking::Connectivity;
|
2786
|
+
IVectorView<HostName^>^ hostnames = NetworkInformation::GetHostNames();
|
2787
|
+
for (unsigned i = 0; i < hostnames->Size; ++i)
|
2788
|
+
{
|
2789
|
+
HostName^ hostname = hostnames->GetAt(i);
|
2790
|
+
if (hostname->Type == HostNameType::DomainName)
|
2791
|
+
{
|
2792
|
+
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
2793
|
+
std::string raw_name = converter.to_bytes(hostname->RawName->Data());
|
2794
|
+
if (namelen > 0 && raw_name.size() < static_cast<std::size_t>(namelen))
|
2795
|
+
{
|
2796
|
+
strcpy_s(name, namelen, raw_name.c_str());
|
2797
|
+
return 0;
|
2798
|
+
}
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
return -1;
|
2802
|
+
}
|
2803
|
+
catch (Platform::Exception^ e)
|
2804
|
+
{
|
2805
|
+
ec = asio::error_code(e->HResult,
|
2806
|
+
asio::system_category());
|
2807
|
+
return -1;
|
2808
|
+
}
|
2809
|
+
#else // defined(ASIO_WINDOWS_RUNTIME)
|
2810
|
+
int result = ::gethostname(name, namelen);
|
2811
|
+
get_last_error(ec, result != 0);
|
2812
|
+
return result;
|
2813
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
2814
|
+
}
|
2815
|
+
|
2816
|
+
#if !defined(ASIO_WINDOWS_RUNTIME)
|
2817
|
+
|
2818
|
+
#if !defined(ASIO_HAS_GETADDRINFO)
|
2819
|
+
|
2820
|
+
// The following functions are only needed for emulation of getaddrinfo and
|
2821
|
+
// getnameinfo.
|
2822
|
+
|
2823
|
+
inline asio::error_code translate_netdb_error(int error)
|
2824
|
+
{
|
2825
|
+
switch (error)
|
2826
|
+
{
|
2827
|
+
case 0:
|
2828
|
+
return asio::error_code();
|
2829
|
+
case HOST_NOT_FOUND:
|
2830
|
+
return asio::error::host_not_found;
|
2831
|
+
case TRY_AGAIN:
|
2832
|
+
return asio::error::host_not_found_try_again;
|
2833
|
+
case NO_RECOVERY:
|
2834
|
+
return asio::error::no_recovery;
|
2835
|
+
case NO_DATA:
|
2836
|
+
return asio::error::no_data;
|
2837
|
+
default:
|
2838
|
+
ASIO_ASSERT(false);
|
2839
|
+
return asio::error::invalid_argument;
|
2840
|
+
}
|
2841
|
+
}
|
2842
|
+
|
2843
|
+
inline hostent* gethostbyaddr(const char* addr, int length, int af,
|
2844
|
+
hostent* result, char* buffer, int buflength, asio::error_code& ec)
|
2845
|
+
{
|
2846
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2847
|
+
(void)(buffer);
|
2848
|
+
(void)(buflength);
|
2849
|
+
hostent* retval = ::gethostbyaddr(addr, length, af);
|
2850
|
+
get_last_error(ec, !retval);
|
2851
|
+
if (!retval)
|
2852
|
+
return 0;
|
2853
|
+
*result = *retval;
|
2854
|
+
return retval;
|
2855
|
+
#elif defined(__sun) || defined(__QNX__)
|
2856
|
+
int error = 0;
|
2857
|
+
hostent* retval = ::gethostbyaddr_r(addr, length,
|
2858
|
+
af, result, buffer, buflength, &error);
|
2859
|
+
get_last_error(ec, !retval);
|
2860
|
+
if (error)
|
2861
|
+
ec = translate_netdb_error(error);
|
2862
|
+
return retval;
|
2863
|
+
#elif defined(__MACH__) && defined(__APPLE__)
|
2864
|
+
(void)(buffer);
|
2865
|
+
(void)(buflength);
|
2866
|
+
int error = 0;
|
2867
|
+
hostent* retval = ::getipnodebyaddr(addr, length, af, &error);
|
2868
|
+
get_last_error(ec, !retval);
|
2869
|
+
if (error)
|
2870
|
+
ec = translate_netdb_error(error);
|
2871
|
+
if (!retval)
|
2872
|
+
return 0;
|
2873
|
+
*result = *retval;
|
2874
|
+
return retval;
|
2875
|
+
#else
|
2876
|
+
hostent* retval = 0;
|
2877
|
+
int error = 0;
|
2878
|
+
clear_last_error();
|
2879
|
+
::gethostbyaddr_r(addr, length, af, result,
|
2880
|
+
buffer, buflength, &retval, &error);
|
2881
|
+
get_last_error(ec, true);
|
2882
|
+
if (error)
|
2883
|
+
ec = translate_netdb_error(error);
|
2884
|
+
return retval;
|
2885
|
+
#endif
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
inline hostent* gethostbyname(const char* name, int af, struct hostent* result,
|
2889
|
+
char* buffer, int buflength, int ai_flags, asio::error_code& ec)
|
2890
|
+
{
|
2891
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
2892
|
+
(void)(buffer);
|
2893
|
+
(void)(buflength);
|
2894
|
+
(void)(ai_flags);
|
2895
|
+
if (af != ASIO_OS_DEF(AF_INET))
|
2896
|
+
{
|
2897
|
+
ec = asio::error::address_family_not_supported;
|
2898
|
+
return 0;
|
2899
|
+
}
|
2900
|
+
hostent* retval = ::gethostbyname(name);
|
2901
|
+
get_last_error(ec, !retval);
|
2902
|
+
if (!retval)
|
2903
|
+
return 0;
|
2904
|
+
*result = *retval;
|
2905
|
+
return result;
|
2906
|
+
#elif defined(__sun) || defined(__QNX__)
|
2907
|
+
(void)(ai_flags);
|
2908
|
+
if (af != ASIO_OS_DEF(AF_INET))
|
2909
|
+
{
|
2910
|
+
ec = asio::error::address_family_not_supported;
|
2911
|
+
return 0;
|
2912
|
+
}
|
2913
|
+
int error = 0;
|
2914
|
+
hostent* retval = ::gethostbyname_r(name, result, buffer, buflength, &error);
|
2915
|
+
get_last_error(ec, !retval);
|
2916
|
+
if (error)
|
2917
|
+
ec = translate_netdb_error(error);
|
2918
|
+
return retval;
|
2919
|
+
#elif defined(__MACH__) && defined(__APPLE__)
|
2920
|
+
(void)(buffer);
|
2921
|
+
(void)(buflength);
|
2922
|
+
int error = 0;
|
2923
|
+
hostent* retval = ::getipnodebyname(name, af, ai_flags, &error);
|
2924
|
+
get_last_error(ec, !retval);
|
2925
|
+
if (error)
|
2926
|
+
ec = translate_netdb_error(error);
|
2927
|
+
if (!retval)
|
2928
|
+
return 0;
|
2929
|
+
*result = *retval;
|
2930
|
+
return retval;
|
2931
|
+
#else
|
2932
|
+
(void)(ai_flags);
|
2933
|
+
if (af != ASIO_OS_DEF(AF_INET))
|
2934
|
+
{
|
2935
|
+
ec = asio::error::address_family_not_supported;
|
2936
|
+
return 0;
|
2937
|
+
}
|
2938
|
+
hostent* retval = 0;
|
2939
|
+
int error = 0;
|
2940
|
+
clear_last_error();
|
2941
|
+
::gethostbyname_r(name, result, buffer, buflength, &retval, &error);
|
2942
|
+
get_last_error(ec, true);
|
2943
|
+
if (error)
|
2944
|
+
ec = translate_netdb_error(error);
|
2945
|
+
return retval;
|
2946
|
+
#endif
|
2947
|
+
}
|
2948
|
+
|
2949
|
+
inline void freehostent(hostent* h)
|
2950
|
+
{
|
2951
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
2952
|
+
if (h)
|
2953
|
+
::freehostent(h);
|
2954
|
+
#else
|
2955
|
+
(void)(h);
|
2956
|
+
#endif
|
2957
|
+
}
|
2958
|
+
|
2959
|
+
// Emulation of getaddrinfo based on implementation in:
|
2960
|
+
// Stevens, W. R., UNIX Network Programming Vol. 1, 2nd Ed., Prentice-Hall 1998.
|
2961
|
+
|
2962
|
+
struct gai_search
|
2963
|
+
{
|
2964
|
+
const char* host;
|
2965
|
+
int family;
|
2966
|
+
};
|
2967
|
+
|
2968
|
+
inline int gai_nsearch(const char* host,
|
2969
|
+
const addrinfo_type* hints, gai_search (&search)[2])
|
2970
|
+
{
|
2971
|
+
int search_count = 0;
|
2972
|
+
if (host == 0 || host[0] == '\0')
|
2973
|
+
{
|
2974
|
+
if (hints->ai_flags & AI_PASSIVE)
|
2975
|
+
{
|
2976
|
+
// No host and AI_PASSIVE implies wildcard bind.
|
2977
|
+
switch (hints->ai_family)
|
2978
|
+
{
|
2979
|
+
case ASIO_OS_DEF(AF_INET):
|
2980
|
+
search[search_count].host = "0.0.0.0";
|
2981
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
2982
|
+
++search_count;
|
2983
|
+
break;
|
2984
|
+
case ASIO_OS_DEF(AF_INET6):
|
2985
|
+
search[search_count].host = "0::0";
|
2986
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
2987
|
+
++search_count;
|
2988
|
+
break;
|
2989
|
+
case ASIO_OS_DEF(AF_UNSPEC):
|
2990
|
+
search[search_count].host = "0::0";
|
2991
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
2992
|
+
++search_count;
|
2993
|
+
search[search_count].host = "0.0.0.0";
|
2994
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
2995
|
+
++search_count;
|
2996
|
+
break;
|
2997
|
+
default:
|
2998
|
+
break;
|
2999
|
+
}
|
3000
|
+
}
|
3001
|
+
else
|
3002
|
+
{
|
3003
|
+
// No host and not AI_PASSIVE means connect to local host.
|
3004
|
+
switch (hints->ai_family)
|
3005
|
+
{
|
3006
|
+
case ASIO_OS_DEF(AF_INET):
|
3007
|
+
search[search_count].host = "localhost";
|
3008
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
3009
|
+
++search_count;
|
3010
|
+
break;
|
3011
|
+
case ASIO_OS_DEF(AF_INET6):
|
3012
|
+
search[search_count].host = "localhost";
|
3013
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
3014
|
+
++search_count;
|
3015
|
+
break;
|
3016
|
+
case ASIO_OS_DEF(AF_UNSPEC):
|
3017
|
+
search[search_count].host = "localhost";
|
3018
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
3019
|
+
++search_count;
|
3020
|
+
search[search_count].host = "localhost";
|
3021
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
3022
|
+
++search_count;
|
3023
|
+
break;
|
3024
|
+
default:
|
3025
|
+
break;
|
3026
|
+
}
|
3027
|
+
}
|
3028
|
+
}
|
3029
|
+
else
|
3030
|
+
{
|
3031
|
+
// Host is specified.
|
3032
|
+
switch (hints->ai_family)
|
3033
|
+
{
|
3034
|
+
case ASIO_OS_DEF(AF_INET):
|
3035
|
+
search[search_count].host = host;
|
3036
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
3037
|
+
++search_count;
|
3038
|
+
break;
|
3039
|
+
case ASIO_OS_DEF(AF_INET6):
|
3040
|
+
search[search_count].host = host;
|
3041
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
3042
|
+
++search_count;
|
3043
|
+
break;
|
3044
|
+
case ASIO_OS_DEF(AF_UNSPEC):
|
3045
|
+
search[search_count].host = host;
|
3046
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET6);
|
3047
|
+
++search_count;
|
3048
|
+
search[search_count].host = host;
|
3049
|
+
search[search_count].family = ASIO_OS_DEF(AF_INET);
|
3050
|
+
++search_count;
|
3051
|
+
break;
|
3052
|
+
default:
|
3053
|
+
break;
|
3054
|
+
}
|
3055
|
+
}
|
3056
|
+
return search_count;
|
3057
|
+
}
|
3058
|
+
|
3059
|
+
template <typename T>
|
3060
|
+
inline T* gai_alloc(std::size_t size = sizeof(T))
|
3061
|
+
{
|
3062
|
+
using namespace std;
|
3063
|
+
T* p = static_cast<T*>(::operator new(size, std::nothrow));
|
3064
|
+
if (p)
|
3065
|
+
memset(p, 0, size);
|
3066
|
+
return p;
|
3067
|
+
}
|
3068
|
+
|
3069
|
+
inline void gai_free(void* p)
|
3070
|
+
{
|
3071
|
+
::operator delete(p);
|
3072
|
+
}
|
3073
|
+
|
3074
|
+
inline void gai_strcpy(char* target, const char* source, std::size_t max_size)
|
3075
|
+
{
|
3076
|
+
using namespace std;
|
3077
|
+
#if defined(ASIO_HAS_SECURE_RTL)
|
3078
|
+
strcpy_s(target, max_size, source);
|
3079
|
+
#else // defined(ASIO_HAS_SECURE_RTL)
|
3080
|
+
*target = 0;
|
3081
|
+
if (max_size > 0)
|
3082
|
+
strncat(target, source, max_size - 1);
|
3083
|
+
#endif // defined(ASIO_HAS_SECURE_RTL)
|
3084
|
+
}
|
3085
|
+
|
3086
|
+
enum { gai_clone_flag = 1 << 30 };
|
3087
|
+
|
3088
|
+
inline int gai_aistruct(addrinfo_type*** next, const addrinfo_type* hints,
|
3089
|
+
const void* addr, int family)
|
3090
|
+
{
|
3091
|
+
using namespace std;
|
3092
|
+
|
3093
|
+
addrinfo_type* ai = gai_alloc<addrinfo_type>();
|
3094
|
+
if (ai == 0)
|
3095
|
+
return EAI_MEMORY;
|
3096
|
+
|
3097
|
+
ai->ai_next = 0;
|
3098
|
+
**next = ai;
|
3099
|
+
*next = &ai->ai_next;
|
3100
|
+
|
3101
|
+
ai->ai_canonname = 0;
|
3102
|
+
ai->ai_socktype = hints->ai_socktype;
|
3103
|
+
if (ai->ai_socktype == 0)
|
3104
|
+
ai->ai_flags |= gai_clone_flag;
|
3105
|
+
ai->ai_protocol = hints->ai_protocol;
|
3106
|
+
ai->ai_family = family;
|
3107
|
+
|
3108
|
+
switch (ai->ai_family)
|
3109
|
+
{
|
3110
|
+
case ASIO_OS_DEF(AF_INET):
|
3111
|
+
{
|
3112
|
+
sockaddr_in4_type* sinptr = gai_alloc<sockaddr_in4_type>();
|
3113
|
+
if (sinptr == 0)
|
3114
|
+
return EAI_MEMORY;
|
3115
|
+
sinptr->sin_family = ASIO_OS_DEF(AF_INET);
|
3116
|
+
memcpy(&sinptr->sin_addr, addr, sizeof(in4_addr_type));
|
3117
|
+
ai->ai_addr = reinterpret_cast<sockaddr*>(sinptr);
|
3118
|
+
ai->ai_addrlen = sizeof(sockaddr_in4_type);
|
3119
|
+
break;
|
3120
|
+
}
|
3121
|
+
case ASIO_OS_DEF(AF_INET6):
|
3122
|
+
{
|
3123
|
+
sockaddr_in6_type* sin6ptr = gai_alloc<sockaddr_in6_type>();
|
3124
|
+
if (sin6ptr == 0)
|
3125
|
+
return EAI_MEMORY;
|
3126
|
+
sin6ptr->sin6_family = ASIO_OS_DEF(AF_INET6);
|
3127
|
+
memcpy(&sin6ptr->sin6_addr, addr, sizeof(in6_addr_type));
|
3128
|
+
ai->ai_addr = reinterpret_cast<sockaddr*>(sin6ptr);
|
3129
|
+
ai->ai_addrlen = sizeof(sockaddr_in6_type);
|
3130
|
+
break;
|
3131
|
+
}
|
3132
|
+
default:
|
3133
|
+
break;
|
3134
|
+
}
|
3135
|
+
|
3136
|
+
return 0;
|
3137
|
+
}
|
3138
|
+
|
3139
|
+
inline addrinfo_type* gai_clone(addrinfo_type* ai)
|
3140
|
+
{
|
3141
|
+
using namespace std;
|
3142
|
+
|
3143
|
+
addrinfo_type* new_ai = gai_alloc<addrinfo_type>();
|
3144
|
+
if (new_ai == 0)
|
3145
|
+
return new_ai;
|
3146
|
+
|
3147
|
+
new_ai->ai_next = ai->ai_next;
|
3148
|
+
ai->ai_next = new_ai;
|
3149
|
+
|
3150
|
+
new_ai->ai_flags = 0;
|
3151
|
+
new_ai->ai_family = ai->ai_family;
|
3152
|
+
new_ai->ai_socktype = ai->ai_socktype;
|
3153
|
+
new_ai->ai_protocol = ai->ai_protocol;
|
3154
|
+
new_ai->ai_canonname = 0;
|
3155
|
+
new_ai->ai_addrlen = ai->ai_addrlen;
|
3156
|
+
new_ai->ai_addr = gai_alloc<sockaddr>(ai->ai_addrlen);
|
3157
|
+
memcpy(new_ai->ai_addr, ai->ai_addr, ai->ai_addrlen);
|
3158
|
+
|
3159
|
+
return new_ai;
|
3160
|
+
}
|
3161
|
+
|
3162
|
+
inline int gai_port(addrinfo_type* aihead, int port, int socktype)
|
3163
|
+
{
|
3164
|
+
int num_found = 0;
|
3165
|
+
|
3166
|
+
for (addrinfo_type* ai = aihead; ai; ai = ai->ai_next)
|
3167
|
+
{
|
3168
|
+
if (ai->ai_flags & gai_clone_flag)
|
3169
|
+
{
|
3170
|
+
if (ai->ai_socktype != 0)
|
3171
|
+
{
|
3172
|
+
ai = gai_clone(ai);
|
3173
|
+
if (ai == 0)
|
3174
|
+
return -1;
|
3175
|
+
// ai now points to newly cloned entry.
|
3176
|
+
}
|
3177
|
+
}
|
3178
|
+
else if (ai->ai_socktype != socktype)
|
3179
|
+
{
|
3180
|
+
// Ignore if mismatch on socket type.
|
3181
|
+
continue;
|
3182
|
+
}
|
3183
|
+
|
3184
|
+
ai->ai_socktype = socktype;
|
3185
|
+
|
3186
|
+
switch (ai->ai_family)
|
3187
|
+
{
|
3188
|
+
case ASIO_OS_DEF(AF_INET):
|
3189
|
+
{
|
3190
|
+
sockaddr_in4_type* sinptr =
|
3191
|
+
reinterpret_cast<sockaddr_in4_type*>(ai->ai_addr);
|
3192
|
+
sinptr->sin_port = port;
|
3193
|
+
++num_found;
|
3194
|
+
break;
|
3195
|
+
}
|
3196
|
+
case ASIO_OS_DEF(AF_INET6):
|
3197
|
+
{
|
3198
|
+
sockaddr_in6_type* sin6ptr =
|
3199
|
+
reinterpret_cast<sockaddr_in6_type*>(ai->ai_addr);
|
3200
|
+
sin6ptr->sin6_port = port;
|
3201
|
+
++num_found;
|
3202
|
+
break;
|
3203
|
+
}
|
3204
|
+
default:
|
3205
|
+
break;
|
3206
|
+
}
|
3207
|
+
}
|
3208
|
+
|
3209
|
+
return num_found;
|
3210
|
+
}
|
3211
|
+
|
3212
|
+
inline int gai_serv(addrinfo_type* aihead,
|
3213
|
+
const addrinfo_type* hints, const char* serv)
|
3214
|
+
{
|
3215
|
+
using namespace std;
|
3216
|
+
|
3217
|
+
int num_found = 0;
|
3218
|
+
|
3219
|
+
if (
|
3220
|
+
#if defined(AI_NUMERICSERV)
|
3221
|
+
(hints->ai_flags & AI_NUMERICSERV) ||
|
3222
|
+
#endif
|
3223
|
+
isdigit(static_cast<unsigned char>(serv[0])))
|
3224
|
+
{
|
3225
|
+
int port = htons(atoi(serv));
|
3226
|
+
if (hints->ai_socktype)
|
3227
|
+
{
|
3228
|
+
// Caller specifies socket type.
|
3229
|
+
int rc = gai_port(aihead, port, hints->ai_socktype);
|
3230
|
+
if (rc < 0)
|
3231
|
+
return EAI_MEMORY;
|
3232
|
+
num_found += rc;
|
3233
|
+
}
|
3234
|
+
else
|
3235
|
+
{
|
3236
|
+
// Caller does not specify socket type.
|
3237
|
+
int rc = gai_port(aihead, port, SOCK_STREAM);
|
3238
|
+
if (rc < 0)
|
3239
|
+
return EAI_MEMORY;
|
3240
|
+
num_found += rc;
|
3241
|
+
rc = gai_port(aihead, port, SOCK_DGRAM);
|
3242
|
+
if (rc < 0)
|
3243
|
+
return EAI_MEMORY;
|
3244
|
+
num_found += rc;
|
3245
|
+
}
|
3246
|
+
}
|
3247
|
+
else
|
3248
|
+
{
|
3249
|
+
// Try service name with TCP first, then UDP.
|
3250
|
+
if (hints->ai_socktype == 0 || hints->ai_socktype == SOCK_STREAM)
|
3251
|
+
{
|
3252
|
+
servent* sptr = getservbyname(serv, "tcp");
|
3253
|
+
if (sptr != 0)
|
3254
|
+
{
|
3255
|
+
int rc = gai_port(aihead, sptr->s_port, SOCK_STREAM);
|
3256
|
+
if (rc < 0)
|
3257
|
+
return EAI_MEMORY;
|
3258
|
+
num_found += rc;
|
3259
|
+
}
|
3260
|
+
}
|
3261
|
+
if (hints->ai_socktype == 0 || hints->ai_socktype == SOCK_DGRAM)
|
3262
|
+
{
|
3263
|
+
servent* sptr = getservbyname(serv, "udp");
|
3264
|
+
if (sptr != 0)
|
3265
|
+
{
|
3266
|
+
int rc = gai_port(aihead, sptr->s_port, SOCK_DGRAM);
|
3267
|
+
if (rc < 0)
|
3268
|
+
return EAI_MEMORY;
|
3269
|
+
num_found += rc;
|
3270
|
+
}
|
3271
|
+
}
|
3272
|
+
}
|
3273
|
+
|
3274
|
+
if (num_found == 0)
|
3275
|
+
{
|
3276
|
+
if (hints->ai_socktype == 0)
|
3277
|
+
{
|
3278
|
+
// All calls to getservbyname() failed.
|
3279
|
+
return EAI_NONAME;
|
3280
|
+
}
|
3281
|
+
else
|
3282
|
+
{
|
3283
|
+
// Service not supported for socket type.
|
3284
|
+
return EAI_SERVICE;
|
3285
|
+
}
|
3286
|
+
}
|
3287
|
+
|
3288
|
+
return 0;
|
3289
|
+
}
|
3290
|
+
|
3291
|
+
inline int gai_echeck(const char* host, const char* service,
|
3292
|
+
int flags, int family, int socktype, int protocol)
|
3293
|
+
{
|
3294
|
+
(void)(flags);
|
3295
|
+
(void)(protocol);
|
3296
|
+
|
3297
|
+
// Host or service must be specified.
|
3298
|
+
if (host == 0 || host[0] == '\0')
|
3299
|
+
if (service == 0 || service[0] == '\0')
|
3300
|
+
return EAI_NONAME;
|
3301
|
+
|
3302
|
+
// Check combination of family and socket type.
|
3303
|
+
switch (family)
|
3304
|
+
{
|
3305
|
+
case ASIO_OS_DEF(AF_UNSPEC):
|
3306
|
+
break;
|
3307
|
+
case ASIO_OS_DEF(AF_INET):
|
3308
|
+
case ASIO_OS_DEF(AF_INET6):
|
3309
|
+
if (service != 0 && service[0] != '\0')
|
3310
|
+
if (socktype != 0 && socktype != SOCK_STREAM && socktype != SOCK_DGRAM)
|
3311
|
+
return EAI_SOCKTYPE;
|
3312
|
+
break;
|
3313
|
+
default:
|
3314
|
+
return EAI_FAMILY;
|
3315
|
+
}
|
3316
|
+
|
3317
|
+
return 0;
|
3318
|
+
}
|
3319
|
+
|
3320
|
+
inline void freeaddrinfo_emulation(addrinfo_type* aihead)
|
3321
|
+
{
|
3322
|
+
addrinfo_type* ai = aihead;
|
3323
|
+
while (ai)
|
3324
|
+
{
|
3325
|
+
gai_free(ai->ai_addr);
|
3326
|
+
gai_free(ai->ai_canonname);
|
3327
|
+
addrinfo_type* ainext = ai->ai_next;
|
3328
|
+
gai_free(ai);
|
3329
|
+
ai = ainext;
|
3330
|
+
}
|
3331
|
+
}
|
3332
|
+
|
3333
|
+
inline int getaddrinfo_emulation(const char* host, const char* service,
|
3334
|
+
const addrinfo_type* hintsp, addrinfo_type** result)
|
3335
|
+
{
|
3336
|
+
// Set up linked list of addrinfo structures.
|
3337
|
+
addrinfo_type* aihead = 0;
|
3338
|
+
addrinfo_type** ainext = &aihead;
|
3339
|
+
char* canon = 0;
|
3340
|
+
|
3341
|
+
// Supply default hints if not specified by caller.
|
3342
|
+
addrinfo_type hints = addrinfo_type();
|
3343
|
+
hints.ai_family = ASIO_OS_DEF(AF_UNSPEC);
|
3344
|
+
if (hintsp)
|
3345
|
+
hints = *hintsp;
|
3346
|
+
|
3347
|
+
// If the resolution is not specifically for AF_INET6, remove the AI_V4MAPPED
|
3348
|
+
// and AI_ALL flags.
|
3349
|
+
#if defined(AI_V4MAPPED)
|
3350
|
+
if (hints.ai_family != ASIO_OS_DEF(AF_INET6))
|
3351
|
+
hints.ai_flags &= ~AI_V4MAPPED;
|
3352
|
+
#endif
|
3353
|
+
#if defined(AI_ALL)
|
3354
|
+
if (hints.ai_family != ASIO_OS_DEF(AF_INET6))
|
3355
|
+
hints.ai_flags &= ~AI_ALL;
|
3356
|
+
#endif
|
3357
|
+
|
3358
|
+
// Basic error checking.
|
3359
|
+
int rc = gai_echeck(host, service, hints.ai_flags, hints.ai_family,
|
3360
|
+
hints.ai_socktype, hints.ai_protocol);
|
3361
|
+
if (rc != 0)
|
3362
|
+
{
|
3363
|
+
freeaddrinfo_emulation(aihead);
|
3364
|
+
return rc;
|
3365
|
+
}
|
3366
|
+
|
3367
|
+
gai_search search[2];
|
3368
|
+
int search_count = gai_nsearch(host, &hints, search);
|
3369
|
+
for (gai_search* sptr = search; sptr < search + search_count; ++sptr)
|
3370
|
+
{
|
3371
|
+
// Check for IPv4 dotted decimal string.
|
3372
|
+
in4_addr_type inaddr;
|
3373
|
+
asio::error_code ec;
|
3374
|
+
if (socket_ops::inet_pton(ASIO_OS_DEF(AF_INET),
|
3375
|
+
sptr->host, &inaddr, 0, ec) == 1)
|
3376
|
+
{
|
3377
|
+
if (hints.ai_family != ASIO_OS_DEF(AF_UNSPEC)
|
3378
|
+
&& hints.ai_family != ASIO_OS_DEF(AF_INET))
|
3379
|
+
{
|
3380
|
+
freeaddrinfo_emulation(aihead);
|
3381
|
+
gai_free(canon);
|
3382
|
+
return EAI_FAMILY;
|
3383
|
+
}
|
3384
|
+
if (sptr->family == ASIO_OS_DEF(AF_INET))
|
3385
|
+
{
|
3386
|
+
rc = gai_aistruct(&ainext, &hints, &inaddr, ASIO_OS_DEF(AF_INET));
|
3387
|
+
if (rc != 0)
|
3388
|
+
{
|
3389
|
+
freeaddrinfo_emulation(aihead);
|
3390
|
+
gai_free(canon);
|
3391
|
+
return rc;
|
3392
|
+
}
|
3393
|
+
}
|
3394
|
+
continue;
|
3395
|
+
}
|
3396
|
+
|
3397
|
+
// Check for IPv6 hex string.
|
3398
|
+
in6_addr_type in6addr;
|
3399
|
+
if (socket_ops::inet_pton(ASIO_OS_DEF(AF_INET6),
|
3400
|
+
sptr->host, &in6addr, 0, ec) == 1)
|
3401
|
+
{
|
3402
|
+
if (hints.ai_family != ASIO_OS_DEF(AF_UNSPEC)
|
3403
|
+
&& hints.ai_family != ASIO_OS_DEF(AF_INET6))
|
3404
|
+
{
|
3405
|
+
freeaddrinfo_emulation(aihead);
|
3406
|
+
gai_free(canon);
|
3407
|
+
return EAI_FAMILY;
|
3408
|
+
}
|
3409
|
+
if (sptr->family == ASIO_OS_DEF(AF_INET6))
|
3410
|
+
{
|
3411
|
+
rc = gai_aistruct(&ainext, &hints, &in6addr,
|
3412
|
+
ASIO_OS_DEF(AF_INET6));
|
3413
|
+
if (rc != 0)
|
3414
|
+
{
|
3415
|
+
freeaddrinfo_emulation(aihead);
|
3416
|
+
gai_free(canon);
|
3417
|
+
return rc;
|
3418
|
+
}
|
3419
|
+
}
|
3420
|
+
continue;
|
3421
|
+
}
|
3422
|
+
|
3423
|
+
// Look up hostname.
|
3424
|
+
hostent hent;
|
3425
|
+
char hbuf[8192] = "";
|
3426
|
+
hostent* hptr = socket_ops::gethostbyname(sptr->host,
|
3427
|
+
sptr->family, &hent, hbuf, sizeof(hbuf), hints.ai_flags, ec);
|
3428
|
+
if (hptr == 0)
|
3429
|
+
{
|
3430
|
+
if (search_count == 2)
|
3431
|
+
{
|
3432
|
+
// Failure is OK if there are multiple searches.
|
3433
|
+
continue;
|
3434
|
+
}
|
3435
|
+
freeaddrinfo_emulation(aihead);
|
3436
|
+
gai_free(canon);
|
3437
|
+
if (ec == asio::error::host_not_found)
|
3438
|
+
return EAI_NONAME;
|
3439
|
+
if (ec == asio::error::host_not_found_try_again)
|
3440
|
+
return EAI_AGAIN;
|
3441
|
+
if (ec == asio::error::no_recovery)
|
3442
|
+
return EAI_FAIL;
|
3443
|
+
if (ec == asio::error::no_data)
|
3444
|
+
return EAI_NONAME;
|
3445
|
+
return EAI_NONAME;
|
3446
|
+
}
|
3447
|
+
|
3448
|
+
// Check for address family mismatch if one was specified.
|
3449
|
+
if (hints.ai_family != ASIO_OS_DEF(AF_UNSPEC)
|
3450
|
+
&& hints.ai_family != hptr->h_addrtype)
|
3451
|
+
{
|
3452
|
+
freeaddrinfo_emulation(aihead);
|
3453
|
+
gai_free(canon);
|
3454
|
+
socket_ops::freehostent(hptr);
|
3455
|
+
return EAI_FAMILY;
|
3456
|
+
}
|
3457
|
+
|
3458
|
+
// Save canonical name first time.
|
3459
|
+
if (host != 0 && host[0] != '\0' && hptr->h_name && hptr->h_name[0]
|
3460
|
+
&& (hints.ai_flags & AI_CANONNAME) && canon == 0)
|
3461
|
+
{
|
3462
|
+
std::size_t canon_len = strlen(hptr->h_name) + 1;
|
3463
|
+
canon = gai_alloc<char>(canon_len);
|
3464
|
+
if (canon == 0)
|
3465
|
+
{
|
3466
|
+
freeaddrinfo_emulation(aihead);
|
3467
|
+
socket_ops::freehostent(hptr);
|
3468
|
+
return EAI_MEMORY;
|
3469
|
+
}
|
3470
|
+
gai_strcpy(canon, hptr->h_name, canon_len);
|
3471
|
+
}
|
3472
|
+
|
3473
|
+
// Create an addrinfo structure for each returned address.
|
3474
|
+
for (char** ap = hptr->h_addr_list; *ap; ++ap)
|
3475
|
+
{
|
3476
|
+
rc = gai_aistruct(&ainext, &hints, *ap, hptr->h_addrtype);
|
3477
|
+
if (rc != 0)
|
3478
|
+
{
|
3479
|
+
freeaddrinfo_emulation(aihead);
|
3480
|
+
gai_free(canon);
|
3481
|
+
socket_ops::freehostent(hptr);
|
3482
|
+
return EAI_FAMILY;
|
3483
|
+
}
|
3484
|
+
}
|
3485
|
+
|
3486
|
+
socket_ops::freehostent(hptr);
|
3487
|
+
}
|
3488
|
+
|
3489
|
+
// Check if we found anything.
|
3490
|
+
if (aihead == 0)
|
3491
|
+
{
|
3492
|
+
gai_free(canon);
|
3493
|
+
return EAI_NONAME;
|
3494
|
+
}
|
3495
|
+
|
3496
|
+
// Return canonical name in first entry.
|
3497
|
+
if (host != 0 && host[0] != '\0' && (hints.ai_flags & AI_CANONNAME))
|
3498
|
+
{
|
3499
|
+
if (canon)
|
3500
|
+
{
|
3501
|
+
aihead->ai_canonname = canon;
|
3502
|
+
canon = 0;
|
3503
|
+
}
|
3504
|
+
else
|
3505
|
+
{
|
3506
|
+
std::size_t canonname_len = strlen(search[0].host) + 1;
|
3507
|
+
aihead->ai_canonname = gai_alloc<char>(canonname_len);
|
3508
|
+
if (aihead->ai_canonname == 0)
|
3509
|
+
{
|
3510
|
+
freeaddrinfo_emulation(aihead);
|
3511
|
+
return EAI_MEMORY;
|
3512
|
+
}
|
3513
|
+
gai_strcpy(aihead->ai_canonname, search[0].host, canonname_len);
|
3514
|
+
}
|
3515
|
+
}
|
3516
|
+
gai_free(canon);
|
3517
|
+
|
3518
|
+
// Process the service name.
|
3519
|
+
if (service != 0 && service[0] != '\0')
|
3520
|
+
{
|
3521
|
+
rc = gai_serv(aihead, &hints, service);
|
3522
|
+
if (rc != 0)
|
3523
|
+
{
|
3524
|
+
freeaddrinfo_emulation(aihead);
|
3525
|
+
return rc;
|
3526
|
+
}
|
3527
|
+
}
|
3528
|
+
|
3529
|
+
// Return result to caller.
|
3530
|
+
*result = aihead;
|
3531
|
+
return 0;
|
3532
|
+
}
|
3533
|
+
|
3534
|
+
inline asio::error_code getnameinfo_emulation(
|
3535
|
+
const socket_addr_type* sa, std::size_t salen, char* host,
|
3536
|
+
std::size_t hostlen, char* serv, std::size_t servlen, int flags,
|
3537
|
+
asio::error_code& ec)
|
3538
|
+
{
|
3539
|
+
using namespace std;
|
3540
|
+
|
3541
|
+
const char* addr;
|
3542
|
+
size_t addr_len;
|
3543
|
+
unsigned short port;
|
3544
|
+
switch (sa->sa_family)
|
3545
|
+
{
|
3546
|
+
case ASIO_OS_DEF(AF_INET):
|
3547
|
+
if (salen != sizeof(sockaddr_in4_type))
|
3548
|
+
{
|
3549
|
+
return ec = asio::error::invalid_argument;
|
3550
|
+
}
|
3551
|
+
addr = reinterpret_cast<const char*>(
|
3552
|
+
&reinterpret_cast<const sockaddr_in4_type*>(sa)->sin_addr);
|
3553
|
+
addr_len = sizeof(in4_addr_type);
|
3554
|
+
port = reinterpret_cast<const sockaddr_in4_type*>(sa)->sin_port;
|
3555
|
+
break;
|
3556
|
+
case ASIO_OS_DEF(AF_INET6):
|
3557
|
+
if (salen != sizeof(sockaddr_in6_type))
|
3558
|
+
{
|
3559
|
+
return ec = asio::error::invalid_argument;
|
3560
|
+
}
|
3561
|
+
addr = reinterpret_cast<const char*>(
|
3562
|
+
&reinterpret_cast<const sockaddr_in6_type*>(sa)->sin6_addr);
|
3563
|
+
addr_len = sizeof(in6_addr_type);
|
3564
|
+
port = reinterpret_cast<const sockaddr_in6_type*>(sa)->sin6_port;
|
3565
|
+
break;
|
3566
|
+
default:
|
3567
|
+
return ec = asio::error::address_family_not_supported;
|
3568
|
+
}
|
3569
|
+
|
3570
|
+
if (host && hostlen > 0)
|
3571
|
+
{
|
3572
|
+
if (flags & NI_NUMERICHOST)
|
3573
|
+
{
|
3574
|
+
if (socket_ops::inet_ntop(sa->sa_family, addr, host, hostlen, 0, ec) == 0)
|
3575
|
+
{
|
3576
|
+
return ec;
|
3577
|
+
}
|
3578
|
+
}
|
3579
|
+
else
|
3580
|
+
{
|
3581
|
+
hostent hent;
|
3582
|
+
char hbuf[8192] = "";
|
3583
|
+
hostent* hptr = socket_ops::gethostbyaddr(addr,
|
3584
|
+
static_cast<int>(addr_len), sa->sa_family,
|
3585
|
+
&hent, hbuf, sizeof(hbuf), ec);
|
3586
|
+
if (hptr && hptr->h_name && hptr->h_name[0] != '\0')
|
3587
|
+
{
|
3588
|
+
if (flags & NI_NOFQDN)
|
3589
|
+
{
|
3590
|
+
char* dot = strchr(hptr->h_name, '.');
|
3591
|
+
if (dot)
|
3592
|
+
{
|
3593
|
+
*dot = 0;
|
3594
|
+
}
|
3595
|
+
}
|
3596
|
+
gai_strcpy(host, hptr->h_name, hostlen);
|
3597
|
+
socket_ops::freehostent(hptr);
|
3598
|
+
}
|
3599
|
+
else
|
3600
|
+
{
|
3601
|
+
socket_ops::freehostent(hptr);
|
3602
|
+
if (flags & NI_NAMEREQD)
|
3603
|
+
{
|
3604
|
+
return ec = asio::error::host_not_found;
|
3605
|
+
}
|
3606
|
+
if (socket_ops::inet_ntop(sa->sa_family,
|
3607
|
+
addr, host, hostlen, 0, ec) == 0)
|
3608
|
+
{
|
3609
|
+
return ec;
|
3610
|
+
}
|
3611
|
+
}
|
3612
|
+
}
|
3613
|
+
}
|
3614
|
+
|
3615
|
+
if (serv && servlen > 0)
|
3616
|
+
{
|
3617
|
+
if (flags & NI_NUMERICSERV)
|
3618
|
+
{
|
3619
|
+
if (servlen < 6)
|
3620
|
+
{
|
3621
|
+
return ec = asio::error::no_buffer_space;
|
3622
|
+
}
|
3623
|
+
#if defined(ASIO_HAS_SECURE_RTL)
|
3624
|
+
sprintf_s(serv, servlen, "%u", ntohs(port));
|
3625
|
+
#else // defined(ASIO_HAS_SECURE_RTL)
|
3626
|
+
sprintf(serv, "%u", ntohs(port));
|
3627
|
+
#endif // defined(ASIO_HAS_SECURE_RTL)
|
3628
|
+
}
|
3629
|
+
else
|
3630
|
+
{
|
3631
|
+
#if defined(ASIO_HAS_PTHREADS)
|
3632
|
+
static ::pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
3633
|
+
::pthread_mutex_lock(&mutex);
|
3634
|
+
#endif // defined(ASIO_HAS_PTHREADS)
|
3635
|
+
servent* sptr = ::getservbyport(port, (flags & NI_DGRAM) ? "udp" : 0);
|
3636
|
+
if (sptr && sptr->s_name && sptr->s_name[0] != '\0')
|
3637
|
+
{
|
3638
|
+
gai_strcpy(serv, sptr->s_name, servlen);
|
3639
|
+
}
|
3640
|
+
else
|
3641
|
+
{
|
3642
|
+
if (servlen < 6)
|
3643
|
+
{
|
3644
|
+
return ec = asio::error::no_buffer_space;
|
3645
|
+
}
|
3646
|
+
#if defined(ASIO_HAS_SECURE_RTL)
|
3647
|
+
sprintf_s(serv, servlen, "%u", ntohs(port));
|
3648
|
+
#else // defined(ASIO_HAS_SECURE_RTL)
|
3649
|
+
sprintf(serv, "%u", ntohs(port));
|
3650
|
+
#endif // defined(ASIO_HAS_SECURE_RTL)
|
3651
|
+
}
|
3652
|
+
#if defined(ASIO_HAS_PTHREADS)
|
3653
|
+
::pthread_mutex_unlock(&mutex);
|
3654
|
+
#endif // defined(ASIO_HAS_PTHREADS)
|
3655
|
+
}
|
3656
|
+
}
|
3657
|
+
|
3658
|
+
ec.assign(0, ec.category());
|
3659
|
+
return ec;
|
3660
|
+
}
|
3661
|
+
|
3662
|
+
#endif // !defined(ASIO_HAS_GETADDRINFO)
|
3663
|
+
|
3664
|
+
inline asio::error_code translate_addrinfo_error(int error)
|
3665
|
+
{
|
3666
|
+
switch (error)
|
3667
|
+
{
|
3668
|
+
case 0:
|
3669
|
+
return asio::error_code();
|
3670
|
+
case EAI_AGAIN:
|
3671
|
+
return asio::error::host_not_found_try_again;
|
3672
|
+
case EAI_BADFLAGS:
|
3673
|
+
return asio::error::invalid_argument;
|
3674
|
+
case EAI_FAIL:
|
3675
|
+
return asio::error::no_recovery;
|
3676
|
+
case EAI_FAMILY:
|
3677
|
+
return asio::error::address_family_not_supported;
|
3678
|
+
case EAI_MEMORY:
|
3679
|
+
return asio::error::no_memory;
|
3680
|
+
case EAI_NONAME:
|
3681
|
+
#if defined(EAI_ADDRFAMILY)
|
3682
|
+
case EAI_ADDRFAMILY:
|
3683
|
+
#endif
|
3684
|
+
#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME)
|
3685
|
+
case EAI_NODATA:
|
3686
|
+
#endif
|
3687
|
+
return asio::error::host_not_found;
|
3688
|
+
case EAI_SERVICE:
|
3689
|
+
return asio::error::service_not_found;
|
3690
|
+
case EAI_SOCKTYPE:
|
3691
|
+
return asio::error::socket_type_not_supported;
|
3692
|
+
default: // Possibly the non-portable EAI_SYSTEM.
|
3693
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
3694
|
+
return asio::error_code(
|
3695
|
+
WSAGetLastError(), asio::error::get_system_category());
|
3696
|
+
#else
|
3697
|
+
return asio::error_code(
|
3698
|
+
errno, asio::error::get_system_category());
|
3699
|
+
#endif
|
3700
|
+
}
|
3701
|
+
}
|
3702
|
+
|
3703
|
+
asio::error_code getaddrinfo(const char* host,
|
3704
|
+
const char* service, const addrinfo_type& hints,
|
3705
|
+
addrinfo_type** result, asio::error_code& ec)
|
3706
|
+
{
|
3707
|
+
host = (host && *host) ? host : 0;
|
3708
|
+
service = (service && *service) ? service : 0;
|
3709
|
+
clear_last_error();
|
3710
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
3711
|
+
# if defined(ASIO_HAS_GETADDRINFO)
|
3712
|
+
// Building for Windows XP, Windows Server 2003, or later.
|
3713
|
+
int error = ::getaddrinfo(host, service, &hints, result);
|
3714
|
+
return ec = translate_addrinfo_error(error);
|
3715
|
+
# else
|
3716
|
+
// Building for Windows 2000 or earlier.
|
3717
|
+
typedef int (WSAAPI *gai_t)(const char*,
|
3718
|
+
const char*, const addrinfo_type*, addrinfo_type**);
|
3719
|
+
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
|
3720
|
+
{
|
3721
|
+
if (gai_t gai = (gai_t)::GetProcAddress(winsock_module, "getaddrinfo"))
|
3722
|
+
{
|
3723
|
+
int error = gai(host, service, &hints, result);
|
3724
|
+
return ec = translate_addrinfo_error(error);
|
3725
|
+
}
|
3726
|
+
}
|
3727
|
+
int error = getaddrinfo_emulation(host, service, &hints, result);
|
3728
|
+
return ec = translate_addrinfo_error(error);
|
3729
|
+
# endif
|
3730
|
+
#elif !defined(ASIO_HAS_GETADDRINFO)
|
3731
|
+
int error = getaddrinfo_emulation(host, service, &hints, result);
|
3732
|
+
return ec = translate_addrinfo_error(error);
|
3733
|
+
#else
|
3734
|
+
int error = ::getaddrinfo(host, service, &hints, result);
|
3735
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
3736
|
+
using namespace std; // For isdigit and atoi.
|
3737
|
+
if (error == 0 && service && isdigit(static_cast<unsigned char>(service[0])))
|
3738
|
+
{
|
3739
|
+
u_short_type port = host_to_network_short(atoi(service));
|
3740
|
+
for (addrinfo_type* ai = *result; ai; ai = ai->ai_next)
|
3741
|
+
{
|
3742
|
+
switch (ai->ai_family)
|
3743
|
+
{
|
3744
|
+
case ASIO_OS_DEF(AF_INET):
|
3745
|
+
{
|
3746
|
+
sockaddr_in4_type* sinptr =
|
3747
|
+
reinterpret_cast<sockaddr_in4_type*>(ai->ai_addr);
|
3748
|
+
if (sinptr->sin_port == 0)
|
3749
|
+
sinptr->sin_port = port;
|
3750
|
+
break;
|
3751
|
+
}
|
3752
|
+
case ASIO_OS_DEF(AF_INET6):
|
3753
|
+
{
|
3754
|
+
sockaddr_in6_type* sin6ptr =
|
3755
|
+
reinterpret_cast<sockaddr_in6_type*>(ai->ai_addr);
|
3756
|
+
if (sin6ptr->sin6_port == 0)
|
3757
|
+
sin6ptr->sin6_port = port;
|
3758
|
+
break;
|
3759
|
+
}
|
3760
|
+
default:
|
3761
|
+
break;
|
3762
|
+
}
|
3763
|
+
}
|
3764
|
+
}
|
3765
|
+
#endif
|
3766
|
+
return ec = translate_addrinfo_error(error);
|
3767
|
+
#endif
|
3768
|
+
}
|
3769
|
+
|
3770
|
+
asio::error_code background_getaddrinfo(
|
3771
|
+
const weak_cancel_token_type& cancel_token, const char* host,
|
3772
|
+
const char* service, const addrinfo_type& hints,
|
3773
|
+
addrinfo_type** result, asio::error_code& ec)
|
3774
|
+
{
|
3775
|
+
if (cancel_token.expired())
|
3776
|
+
ec = asio::error::operation_aborted;
|
3777
|
+
else
|
3778
|
+
socket_ops::getaddrinfo(host, service, hints, result, ec);
|
3779
|
+
return ec;
|
3780
|
+
}
|
3781
|
+
|
3782
|
+
void freeaddrinfo(addrinfo_type* ai)
|
3783
|
+
{
|
3784
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
3785
|
+
# if defined(ASIO_HAS_GETADDRINFO)
|
3786
|
+
// Building for Windows XP, Windows Server 2003, or later.
|
3787
|
+
::freeaddrinfo(ai);
|
3788
|
+
# else
|
3789
|
+
// Building for Windows 2000 or earlier.
|
3790
|
+
typedef int (WSAAPI *fai_t)(addrinfo_type*);
|
3791
|
+
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
|
3792
|
+
{
|
3793
|
+
if (fai_t fai = (fai_t)::GetProcAddress(winsock_module, "freeaddrinfo"))
|
3794
|
+
{
|
3795
|
+
fai(ai);
|
3796
|
+
return;
|
3797
|
+
}
|
3798
|
+
}
|
3799
|
+
freeaddrinfo_emulation(ai);
|
3800
|
+
# endif
|
3801
|
+
#elif !defined(ASIO_HAS_GETADDRINFO)
|
3802
|
+
freeaddrinfo_emulation(ai);
|
3803
|
+
#else
|
3804
|
+
::freeaddrinfo(ai);
|
3805
|
+
#endif
|
3806
|
+
}
|
3807
|
+
|
3808
|
+
asio::error_code getnameinfo(const socket_addr_type* addr,
|
3809
|
+
std::size_t addrlen, char* host, std::size_t hostlen,
|
3810
|
+
char* serv, std::size_t servlen, int flags, asio::error_code& ec)
|
3811
|
+
{
|
3812
|
+
#if defined(ASIO_WINDOWS) || defined(__CYGWIN__)
|
3813
|
+
# if defined(ASIO_HAS_GETADDRINFO)
|
3814
|
+
// Building for Windows XP, Windows Server 2003, or later.
|
3815
|
+
clear_last_error();
|
3816
|
+
int error = ::getnameinfo(addr, static_cast<socklen_t>(addrlen),
|
3817
|
+
host, static_cast<DWORD>(hostlen),
|
3818
|
+
serv, static_cast<DWORD>(servlen), flags);
|
3819
|
+
return ec = translate_addrinfo_error(error);
|
3820
|
+
# else
|
3821
|
+
// Building for Windows 2000 or earlier.
|
3822
|
+
typedef int (WSAAPI *gni_t)(const socket_addr_type*,
|
3823
|
+
int, char*, DWORD, char*, DWORD, int);
|
3824
|
+
if (HMODULE winsock_module = ::GetModuleHandleA("ws2_32"))
|
3825
|
+
{
|
3826
|
+
if (gni_t gni = (gni_t)::GetProcAddress(winsock_module, "getnameinfo"))
|
3827
|
+
{
|
3828
|
+
clear_last_error();
|
3829
|
+
int error = gni(addr, static_cast<int>(addrlen),
|
3830
|
+
host, static_cast<DWORD>(hostlen),
|
3831
|
+
serv, static_cast<DWORD>(servlen), flags);
|
3832
|
+
return ec = translate_addrinfo_error(error);
|
3833
|
+
}
|
3834
|
+
}
|
3835
|
+
clear_last_error();
|
3836
|
+
return getnameinfo_emulation(addr, addrlen,
|
3837
|
+
host, hostlen, serv, servlen, flags, ec);
|
3838
|
+
# endif
|
3839
|
+
#elif !defined(ASIO_HAS_GETADDRINFO)
|
3840
|
+
using namespace std; // For memcpy.
|
3841
|
+
sockaddr_storage_type tmp_addr;
|
3842
|
+
memcpy(&tmp_addr, addr, addrlen);
|
3843
|
+
addr = reinterpret_cast<socket_addr_type*>(&tmp_addr);
|
3844
|
+
clear_last_error();
|
3845
|
+
return getnameinfo_emulation(addr, addrlen,
|
3846
|
+
host, hostlen, serv, servlen, flags, ec);
|
3847
|
+
#else
|
3848
|
+
clear_last_error();
|
3849
|
+
int error = ::getnameinfo(addr, addrlen, host, hostlen, serv, servlen, flags);
|
3850
|
+
return ec = translate_addrinfo_error(error);
|
3851
|
+
#endif
|
3852
|
+
}
|
3853
|
+
|
3854
|
+
asio::error_code sync_getnameinfo(
|
3855
|
+
const socket_addr_type* addr, std::size_t addrlen,
|
3856
|
+
char* host, std::size_t hostlen, char* serv,
|
3857
|
+
std::size_t servlen, int sock_type, asio::error_code& ec)
|
3858
|
+
{
|
3859
|
+
// First try resolving with the service name. If that fails try resolving
|
3860
|
+
// but allow the service to be returned as a number.
|
3861
|
+
int flags = (sock_type == SOCK_DGRAM) ? NI_DGRAM : 0;
|
3862
|
+
socket_ops::getnameinfo(addr, addrlen, host,
|
3863
|
+
hostlen, serv, servlen, flags, ec);
|
3864
|
+
if (ec)
|
3865
|
+
{
|
3866
|
+
socket_ops::getnameinfo(addr, addrlen, host, hostlen,
|
3867
|
+
serv, servlen, flags | NI_NUMERICSERV, ec);
|
3868
|
+
}
|
3869
|
+
|
3870
|
+
return ec;
|
3871
|
+
}
|
3872
|
+
|
3873
|
+
asio::error_code background_getnameinfo(
|
3874
|
+
const weak_cancel_token_type& cancel_token,
|
3875
|
+
const socket_addr_type* addr, std::size_t addrlen,
|
3876
|
+
char* host, std::size_t hostlen, char* serv,
|
3877
|
+
std::size_t servlen, int sock_type, asio::error_code& ec)
|
3878
|
+
{
|
3879
|
+
if (cancel_token.expired())
|
3880
|
+
{
|
3881
|
+
ec = asio::error::operation_aborted;
|
3882
|
+
}
|
3883
|
+
else
|
3884
|
+
{
|
3885
|
+
// First try resolving with the service name. If that fails try resolving
|
3886
|
+
// but allow the service to be returned as a number.
|
3887
|
+
int flags = (sock_type == SOCK_DGRAM) ? NI_DGRAM : 0;
|
3888
|
+
socket_ops::getnameinfo(addr, addrlen, host,
|
3889
|
+
hostlen, serv, servlen, flags, ec);
|
3890
|
+
if (ec)
|
3891
|
+
{
|
3892
|
+
socket_ops::getnameinfo(addr, addrlen, host, hostlen,
|
3893
|
+
serv, servlen, flags | NI_NUMERICSERV, ec);
|
3894
|
+
}
|
3895
|
+
}
|
3896
|
+
|
3897
|
+
return ec;
|
3898
|
+
}
|
3899
|
+
|
3900
|
+
#endif // !defined(ASIO_WINDOWS_RUNTIME)
|
3901
|
+
|
3902
|
+
u_long_type network_to_host_long(u_long_type value)
|
3903
|
+
{
|
3904
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
3905
|
+
unsigned char* value_p = reinterpret_cast<unsigned char*>(&value);
|
3906
|
+
u_long_type result = (static_cast<u_long_type>(value_p[0]) << 24)
|
3907
|
+
| (static_cast<u_long_type>(value_p[1]) << 16)
|
3908
|
+
| (static_cast<u_long_type>(value_p[2]) << 8)
|
3909
|
+
| static_cast<u_long_type>(value_p[3]);
|
3910
|
+
return result;
|
3911
|
+
#else // defined(ASIO_WINDOWS_RUNTIME)
|
3912
|
+
return ntohl(value);
|
3913
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
3914
|
+
}
|
3915
|
+
|
3916
|
+
u_long_type host_to_network_long(u_long_type value)
|
3917
|
+
{
|
3918
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
3919
|
+
u_long_type result;
|
3920
|
+
unsigned char* result_p = reinterpret_cast<unsigned char*>(&result);
|
3921
|
+
result_p[0] = static_cast<unsigned char>((value >> 24) & 0xFF);
|
3922
|
+
result_p[1] = static_cast<unsigned char>((value >> 16) & 0xFF);
|
3923
|
+
result_p[2] = static_cast<unsigned char>((value >> 8) & 0xFF);
|
3924
|
+
result_p[3] = static_cast<unsigned char>(value & 0xFF);
|
3925
|
+
return result;
|
3926
|
+
#else // defined(ASIO_WINDOWS_RUNTIME)
|
3927
|
+
return htonl(value);
|
3928
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
3929
|
+
}
|
3930
|
+
|
3931
|
+
u_short_type network_to_host_short(u_short_type value)
|
3932
|
+
{
|
3933
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
3934
|
+
unsigned char* value_p = reinterpret_cast<unsigned char*>(&value);
|
3935
|
+
u_short_type result = (static_cast<u_short_type>(value_p[0]) << 8)
|
3936
|
+
| static_cast<u_short_type>(value_p[1]);
|
3937
|
+
return result;
|
3938
|
+
#else // defined(ASIO_WINDOWS_RUNTIME)
|
3939
|
+
return ntohs(value);
|
3940
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
3941
|
+
}
|
3942
|
+
|
3943
|
+
u_short_type host_to_network_short(u_short_type value)
|
3944
|
+
{
|
3945
|
+
#if defined(ASIO_WINDOWS_RUNTIME)
|
3946
|
+
u_short_type result;
|
3947
|
+
unsigned char* result_p = reinterpret_cast<unsigned char*>(&result);
|
3948
|
+
result_p[0] = static_cast<unsigned char>((value >> 8) & 0xFF);
|
3949
|
+
result_p[1] = static_cast<unsigned char>(value & 0xFF);
|
3950
|
+
return result;
|
3951
|
+
#else // defined(ASIO_WINDOWS_RUNTIME)
|
3952
|
+
return htons(value);
|
3953
|
+
#endif // defined(ASIO_WINDOWS_RUNTIME)
|
3954
|
+
}
|
3955
|
+
|
3956
|
+
} // namespace socket_ops
|
3957
|
+
} // namespace detail
|
3958
|
+
} // namespace asio
|
3959
|
+
|
3960
|
+
#include "asio/detail/pop_options.hpp"
|
3961
|
+
|
3962
|
+
#endif // ASIO_DETAIL_SOCKET_OPS_IPP
|