11 #ifndef ASIO_BASIC_SOCKET_HPP 12 #define ASIO_BASIC_SOCKET_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 40 template <
typename Protocol,
typename SocketService>
48 typedef typename SocketService::native_handle_type
native_type;
86 const protocol_type& protocol)
110 const endpoint_type& endpoint)
114 const protocol_type protocol = endpoint.protocol();
135 const protocol_type& protocol,
const native_handle_type& native_socket)
140 protocol, native_socket, ec);
144 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 179 template <
typename Protocol1,
typename SocketService1>
192 template <
typename Protocol1,
typename SocketService1>
194 typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
197 this->
get_service().template converting_move_construct<Protocol1>(
211 template <
typename Protocol1,
typename SocketService1>
217 Protocol1, SocketService1>)(other));
222 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 308 void assign(
const protocol_type& protocol,
309 const native_handle_type& native_socket)
313 protocol, native_socket, ec);
331 protocol, native_socket, ec);
444 #if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \ 445 && (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \ 446 && !defined(ASIO_ENABLE_CANCELIO) 447 __declspec(deprecated(
"By default, this function always fails with " 448 "operation_not_supported when used on Windows XP, Windows Server 2003, " 449 "or earlier. Consult documentation for details."))
492 #if defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) \ 493 && (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600) \ 494 && !defined(ASIO_ENABLE_CANCELIO) 495 __declspec(deprecated(
"By default, this function always fails with " 496 "operation_not_supported when used on Windows XP, Windows Server 2003, " 497 "or earlier. Consult documentation for details."))
589 void bind(
const endpoint_type& endpoint)
648 void connect(
const endpoint_type& peer_endpoint)
654 peer_endpoint.protocol(), ec);
695 peer_endpoint.protocol(), ec))
746 template <
typename ConnectHandler>
749 async_connect(
const endpoint_type& peer_endpoint,
759 const protocol_type protocol = peer_endpoint.protocol();
814 template <
typename SettableSocketOption>
861 template <
typename SettableSocketOption>
904 template <
typename GettableSocketOption>
952 template <
typename GettableSocketOption>
982 template <
typename IoControlCommand>
1017 template <
typename IoControlCommand>
1373 endpoint_type ep = this->
get_service().local_endpoint(
1423 endpoint_type ep = this->
get_service().remote_endpoint(
1518 #endif // ASIO_BASIC_SOCKET_HPP bool at_mark(asio::error_code &ec) const
Determine whether the socket is at the out-of-band data mark.
bool is_open() const
Determine whether the socket is open.
void open(const protocol_type &protocol=protocol_type())
Open the socket using the specified protocol.
void set_option(const SettableSocketOption &option)
Set an option on the socket.
endpoint_type local_endpoint(asio::error_code &ec) const
Get the local endpoint of the socket.
asio::error_code shutdown(shutdown_type what, asio::error_code &ec)
Disable sends or receives on the socket.
void throw_error(const asio::error_code &err)
asio::error_code assign(const protocol_type &protocol, const native_handle_type &native_socket, asio::error_code &ec)
Assign an existing native socket to the socket.
asio::error_code open(const protocol_type &protocol, asio::error_code &ec)
Open the socket using the specified protocol.
#define ASIO_CONNECT_HANDLER_CHECK(handler_type, handler)
Provides core I/O functionality.
service_type & get_service()
Get the service associated with the I/O object.
post(ASIO_MOVE_ARG(CompletionHandler) handler)
Request the io_service to invoke the given handler and return immediately.
#define ASIO_MOVE_CAST2(type1, type2)
endpoint_type local_endpoint() const
Get the local endpoint of the socket.
ASIO_MOVE_ARG(ConnectHandler) handler)
Base class for all I/O objects.
basic_socket< Protocol, SocketService > lowest_layer_type
A basic_socket is always the lowest layer.
asio::error_code close(asio::error_code &ec)
Close the socket.
basic_socket(asio::io_service &io_service, const endpoint_type &endpoint)
asio::basic_streambuf< Allocator > MatchCondition enable_if< is_match_condition< MatchCondition >::value >::type *detail::async_result_init< ReadHandler, void(asio::error_code, std::size_t)> init(ASIO_MOVE_CAST(ReadHandler)(handler))
#define ASIO_HANDLER_TYPE(h, sig)
Protocol protocol_type
The protocol type.
bool at_mark() const
Determine whether the socket is at the out-of-band data mark.
const lowest_layer_type & lowest_layer() const
Get a const reference to the lowest layer.
endpoint_type remote_endpoint(asio::error_code &ec) const
Get the remote endpoint of the socket.
basic_socket(asio::io_service &io_service)
Construct a basic_socket without opening it.
asio::basic_streambuf< Allocator > & b
void assign(const protocol_type &protocol, const native_handle_type &native_socket)
Assign an existing native socket to the socket.
void non_blocking(bool mode)
Sets the non-blocking mode of the socket.
basic_socket(asio::io_service &io_service, const protocol_type &protocol, const native_handle_type &native_socket)
Construct a basic_socket on an existing native socket.
asio::error_code bind(const endpoint_type &endpoint, asio::error_code &ec)
Bind the socket to the given local endpoint.
~basic_socket()
Protected destructor to prevent deletion through this type.
SocketService::native_handle_type native_type
void shutdown(shutdown_type what)
Disable sends or receives on the socket.
bool non_blocking() const
Gets the non-blocking mode of the socket.
void native_non_blocking(bool mode)
Sets the non-blocking mode of the native socket implementation.
void cancel()
Cancel all asynchronous operations associated with the socket.
asio::error_code non_blocking(bool mode, asio::error_code &ec)
Sets the non-blocking mode of the socket.
ASIO_INITFN_RESULT_TYPE(ConnectHandler, void(asio::error_code)) async_connect(const endpoint_type &peer_endpoint
Start an asynchronous connect.
implementation_type & get_implementation()
Get the underlying implementation of the I/O object.
void bind(const endpoint_type &endpoint)
Bind the socket to the given local endpoint.
std::size_t available() const
Determine the number of bytes available for reading.
shutdown_type
Different ways a socket may be shutdown.
void io_control(IoControlCommand &command)
Perform an IO control command on the socket.
asio::error_code get_option(GettableSocketOption &option, asio::error_code &ec) const
Get an option from the socket.
basic_socket(asio::io_service &io_service, const protocol_type &protocol)
Construct and open a basic_socket.
Protocol::endpoint endpoint_type
The endpoint type.
Class to represent an error code value.
native_type native()
(Deprecated: Use native_handle().) Get the native socket representation.
asio::error_code native_non_blocking(bool mode, asio::error_code &ec)
Sets the non-blocking mode of the native socket implementation.
bool native_non_blocking() const
Gets the non-blocking mode of the native socket implementation.
asio::io_service & get_io_service()
Get the io_service associated with the object.
asio::error_code cancel(asio::error_code &ec)
Cancel all asynchronous operations associated with the socket.
void close()
Close the socket.
asio::error_code set_option(const SettableSocketOption &option, asio::error_code &ec)
Set an option on the socket.
void get_option(GettableSocketOption &option) const
Get an option from the socket.
asio::error_code connect(const endpoint_type &peer_endpoint, asio::error_code &ec)
Connect the socket to the specified endpoint.
handler_type< Handler, Signature >::type handler
Provides socket functionality.
#define ASIO_MOVE_CAST(type)
binder1< Handler, Arg1 > bind_handler(Handler handler, const Arg1 &arg1)
async_result< typename handler_type< Handler, Signature >::type > result
SocketService::native_handle_type native_handle_type
The native representation of a socket.
asio::error_code io_control(IoControlCommand &command, asio::error_code &ec)
Perform an IO control command on the socket.
native_handle_type native_handle()
Get the native socket representation.
std::size_t available(asio::error_code &ec) const
Determine the number of bytes available for reading.
endpoint_type remote_endpoint() const
Get the remote endpoint of the socket.
void connect(const endpoint_type &peer_endpoint)
Connect the socket to the specified endpoint.
lowest_layer_type & lowest_layer()
Get a reference to the lowest layer.