$search

asio::basic_socket< Protocol, SocketService > Class Template Reference

Provides socket functionality. More...

#include <basic_socket.hpp>

Inheritance diagram for asio::basic_socket< Protocol, SocketService >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Protocol::endpoint endpoint_type
 The endpoint type.
typedef basic_socket< Protocol,
SocketService > 
lowest_layer_type
 A basic_socket is always the lowest layer.
typedef SocketService::native_type native_type
 The native representation of a socket.
typedef Protocol protocol_type
 The protocol type.

Public Member Functions

asio::error_code assign (const protocol_type &protocol, const native_type &native_socket, asio::error_code &ec)
 Assign an existing native socket to the socket.
void assign (const protocol_type &protocol, const native_type &native_socket)
 Assign an existing native socket to the socket.
template<typename ConnectHandler >
void async_connect (const endpoint_type &peer_endpoint, ConnectHandler handler)
 Start an asynchronous connect.
bool at_mark (asio::error_code &ec) const
 Determine whether the socket is at the out-of-band data mark.
bool at_mark () const
 Determine whether the socket is at the out-of-band data mark.
std::size_t available (asio::error_code &ec) const
 Determine the number of bytes available for reading.
std::size_t available () const
 Determine the number of bytes available for reading.
 basic_socket (asio::io_service &io_service, const protocol_type &protocol, const native_type &native_socket)
 Construct a basic_socket on an existing native socket.
 basic_socket (asio::io_service &io_service, const endpoint_type &endpoint)
 basic_socket (asio::io_service &io_service, const protocol_type &protocol)
 Construct and open a basic_socket.
 basic_socket (asio::io_service &io_service)
 Construct a basic_socket without opening it.
asio::error_code bind (const endpoint_type &endpoint, asio::error_code &ec)
 Bind the socket to the given local endpoint.
void bind (const endpoint_type &endpoint)
 Bind the socket to the given local endpoint.
asio::error_code cancel (asio::error_code &ec)
 Cancel all asynchronous operations associated with the socket.
void cancel ()
 Cancel all asynchronous operations associated with the socket.
asio::error_code close (asio::error_code &ec)
 Close the socket.
void close ()
 Close the socket.
asio::error_code connect (const endpoint_type &peer_endpoint, asio::error_code &ec)
 Connect the socket to the specified endpoint.
void connect (const endpoint_type &peer_endpoint)
 Connect the socket to the specified endpoint.
template<typename GettableSocketOption >
asio::error_code get_option (GettableSocketOption &option, asio::error_code &ec) const
 Get an option from the socket.
template<typename GettableSocketOption >
void get_option (GettableSocketOption &option) const
 Get an option from the socket.
template<typename IoControlCommand >
asio::error_code io_control (IoControlCommand &command, asio::error_code &ec)
 Perform an IO control command on the socket.
template<typename IoControlCommand >
void io_control (IoControlCommand &command)
 Perform an IO control command on the socket.
bool is_open () const
 Determine whether the socket is open.
endpoint_type local_endpoint (asio::error_code &ec) const
 Get the local endpoint of the socket.
endpoint_type local_endpoint () const
 Get the local endpoint of the socket.
lowest_layer_typelowest_layer ()
 Get a reference to the lowest layer.
native_type native ()
 Get the native socket representation.
asio::error_code open (const protocol_type &protocol, asio::error_code &ec)
 Open the socket using the specified protocol.
void open (const protocol_type &protocol=protocol_type())
 Open the socket using the specified protocol.
endpoint_type remote_endpoint (asio::error_code &ec) const
 Get the remote endpoint of the socket.
endpoint_type remote_endpoint () const
 Get the remote endpoint of the socket.
template<typename SettableSocketOption >
asio::error_code set_option (const SettableSocketOption &option, asio::error_code &ec)
 Set an option on the socket.
template<typename SettableSocketOption >
void set_option (const SettableSocketOption &option)
 Set an option on the socket.
asio::error_code shutdown (shutdown_type what, asio::error_code &ec)
 Disable sends or receives on the socket.
void shutdown (shutdown_type what)
 Disable sends or receives on the socket.

Protected Member Functions

 ~basic_socket ()
 Protected destructor to prevent deletion through this type.

Detailed Description

template<typename Protocol, typename SocketService>
class asio::basic_socket< Protocol, SocketService >

Provides socket functionality.

The basic_socket class template provides functionality that is common to both stream-oriented and datagram-oriented sockets.

Thread Safety
Distinct objects: Safe.
Shared objects: Unsafe.

Definition at line 41 of file basic_socket.hpp.


Member Typedef Documentation

template<typename Protocol, typename SocketService>
typedef Protocol::endpoint asio::basic_socket< Protocol, SocketService >::endpoint_type
template<typename Protocol, typename SocketService>
typedef basic_socket<Protocol, SocketService> asio::basic_socket< Protocol, SocketService >::lowest_layer_type

A basic_socket is always the lowest layer.

Definition at line 56 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
typedef SocketService::native_type asio::basic_socket< Protocol, SocketService >::native_type
template<typename Protocol, typename SocketService>
typedef Protocol asio::basic_socket< Protocol, SocketService >::protocol_type

Constructor & Destructor Documentation

template<typename Protocol, typename SocketService>
asio::basic_socket< Protocol, SocketService >::basic_socket ( asio::io_service io_service  )  [inline, explicit]

Construct a basic_socket without opening it.

This constructor creates a socket without opening it.

Parameters:
io_service The io_service object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.

Definition at line 65 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::basic_socket< Protocol, SocketService >::basic_socket ( asio::io_service io_service,
const protocol_type protocol 
) [inline]

Construct and open a basic_socket.

This constructor creates and opens a socket.

Parameters:
io_service The io_service object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.
protocol An object specifying protocol parameters to be used.
Exceptions:
asio::system_error Thrown on failure.

Definition at line 81 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::basic_socket< Protocol, SocketService >::basic_socket ( asio::io_service io_service,
const endpoint_type endpoint 
) [inline]

Construct a basic_socket, opening it and binding it to the given local endpoint. This constructor creates a socket and automatically opens it bound to the specified endpoint on the local machine. The protocol used is the protocol associated with the given endpoint.

Parameters:
io_service The io_service object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.
endpoint An endpoint on the local machine to which the socket will be bound.
Exceptions:
asio::system_error Thrown on failure.

Definition at line 105 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::basic_socket< Protocol, SocketService >::basic_socket ( asio::io_service io_service,
const protocol_type protocol,
const native_type native_socket 
) [inline]

Construct a basic_socket on an existing native socket.

This constructor creates a socket object to hold an existing native socket.

Parameters:
io_service The io_service object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.
protocol An object specifying protocol parameters to be used.
native_socket A native socket.
Exceptions:
asio::system_error Thrown on failure.

Definition at line 129 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::basic_socket< Protocol, SocketService >::~basic_socket (  )  [inline, protected]

Protected destructor to prevent deletion through this type.

Definition at line 1040 of file basic_socket.hpp.


Member Function Documentation

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::assign ( const protocol_type protocol,
const native_type native_socket,
asio::error_code ec 
) [inline]

Assign an existing native socket to the socket.

Definition at line 225 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::assign ( const protocol_type protocol,
const native_type native_socket 
) [inline]

Assign an existing native socket to the socket.

Definition at line 208 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename ConnectHandler >
void asio::basic_socket< Protocol, SocketService >::async_connect ( const endpoint_type peer_endpoint,
ConnectHandler  handler 
) [inline]

Start an asynchronous connect.

This function is used to asynchronously connect a socket to the specified remote endpoint. The function call always returns immediately.

The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.

Parameters:
peer_endpoint The remote endpoint to which the socket will be connected. Copies will be made of the endpoint object as required.
handler The handler to be called when the connection operation completes. Copies will be made of the handler as required. The function signature of the handler must be:

 void handler(
   const asio::error_code& error // Result of operation
 ); 

Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using asio::io_service::post().

Example
 void connect_handler(const asio::error_code& error)
 {
   if (!error)
   {
     // Connect succeeded.
   }
 }

 ...

 asio::ip::tcp::socket socket(io_service);
 asio::ip::tcp::endpoint endpoint(
     asio::ip::address::from_string("1.2.3.4"), 12345);
 socket.async_connect(endpoint, connect_handler);

Definition at line 629 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
bool asio::basic_socket< Protocol, SocketService >::at_mark ( asio::error_code ec  )  const [inline]

Determine whether the socket is at the out-of-band data mark.

This function is used to check whether the socket input is currently positioned at the out-of-band data mark.

Parameters:
ec Set to indicate what error occurred, if any.
Returns:
A bool indicating whether the socket is at the out-of-band data mark.

Definition at line 417 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
bool asio::basic_socket< Protocol, SocketService >::at_mark (  )  const [inline]

Determine whether the socket is at the out-of-band data mark.

This function is used to check whether the socket input is currently positioned at the out-of-band data mark.

Returns:
A bool indicating whether the socket is at the out-of-band data mark.
Exceptions:
asio::system_error Thrown on failure.

Definition at line 399 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
std::size_t asio::basic_socket< Protocol, SocketService >::available ( asio::error_code ec  )  const [inline]

Determine the number of bytes available for reading.

This function is used to determine the number of bytes that may be read without blocking.

Parameters:
ec Set to indicate what error occurred, if any.
Returns:
The number of bytes that may be read without blocking, or 0 if an error occurs.

Definition at line 450 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
std::size_t asio::basic_socket< Protocol, SocketService >::available (  )  const [inline]

Determine the number of bytes available for reading.

This function is used to determine the number of bytes that may be read without blocking.

Returns:
The number of bytes that may be read without blocking, or 0 if an error occurs.
Exceptions:
asio::system_error Thrown on failure.

Definition at line 432 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::bind ( const endpoint_type endpoint,
asio::error_code ec 
) [inline]

Bind the socket to the given local endpoint.

This function binds the socket to the specified endpoint on the local machine.

Parameters:
endpoint An endpoint on the local machine to which the socket will be bound.
ec Set to indicate what error occurred, if any.
Example

Definition at line 503 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::bind ( const endpoint_type endpoint  )  [inline]

Bind the socket to the given local endpoint.

This function binds the socket to the specified endpoint on the local machine.

Parameters:
endpoint An endpoint on the local machine to which the socket will be bound.
Exceptions:
asio::system_error Thrown on failure.
Example

Definition at line 473 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::cancel ( asio::error_code ec  )  [inline]

Cancel all asynchronous operations associated with the socket.

This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the asio::error::operation_aborted error.

Parameters:
ec Set to indicate what error occurred, if any.
Note:
Calls to cancel() will always fail with asio::error::operation_not_supported when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
  • It will only cancel asynchronous operations that were initiated in the current thread.
  • It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.

For portable cancellation, consider using one of the following alternatives:

  • Disable asio's I/O completion port backend by defining ASIO_DISABLE_IOCP.
  • Use the close() function to simultaneously cancel the outstanding operations and close the socket.

When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.

Definition at line 384 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::cancel (  )  [inline]

Cancel all asynchronous operations associated with the socket.

This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the asio::error::operation_aborted error.

Exceptions:
asio::system_error Thrown on failure.
Note:
Calls to cancel() will always fail with asio::error::operation_not_supported when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
  • It will only cancel asynchronous operations that were initiated in the current thread.
  • It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.

For portable cancellation, consider using one of the following alternatives:

  • Disable asio's I/O completion port backend by defining ASIO_DISABLE_IOCP.
  • Use the close() function to simultaneously cancel the outstanding operations and close the socket.

When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.

Definition at line 336 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::close ( asio::error_code ec  )  [inline]

Close the socket.

This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the asio::error::operation_aborted error.

Parameters:
ec Set to indicate what error occurred, if any.
Example
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::error_code ec;
 socket.close(ec);
 if (ec)
 {
   // An error occurred.
 }
Note:
For portable behaviour with respect to graceful closure of a connected socket, call shutdown() before closing the socket.

Definition at line 279 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::close (  )  [inline]

Close the socket.

This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the asio::error::operation_aborted error.

Exceptions:
asio::system_error Thrown on failure.
Note:
For portable behaviour with respect to graceful closure of a connected socket, call shutdown() before closing the socket.

Reimplemented in asio::basic_socket_streambuf< Protocol, StreamSocketService >.

Definition at line 249 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::connect ( const endpoint_type peer_endpoint,
asio::error_code ec 
) [inline]

Connect the socket to the specified endpoint.

This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.

The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.

Parameters:
peer_endpoint The remote endpoint to which the socket will be connected.
ec Set to indicate what error occurred, if any.
Example
 asio::ip::tcp::socket socket(io_service);
 asio::ip::tcp::endpoint endpoint(
     asio::ip::address::from_string("1.2.3.4"), 12345);
 asio::error_code ec;
 socket.connect(endpoint, ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 572 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::connect ( const endpoint_type peer_endpoint  )  [inline]

Connect the socket to the specified endpoint.

This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.

The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.

Parameters:
peer_endpoint The remote endpoint to which the socket will be connected.
Exceptions:
asio::system_error Thrown on failure.
Example

Reimplemented in asio::basic_socket_streambuf< Protocol, StreamSocketService >.

Definition at line 532 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename GettableSocketOption >
asio::error_code asio::basic_socket< Protocol, SocketService >::get_option ( GettableSocketOption &  option,
asio::error_code ec 
) const [inline]

Get an option from the socket.

This function is used to get the current value of an option on the socket.

Parameters:
option The option value to be obtained from the socket.
ec Set to indicate what error occurred, if any.
See also:
GettableSocketOption
asio::socket_base::broadcast
asio::socket_base::do_not_route
asio::socket_base::keep_alive
asio::socket_base::linger
asio::socket_base::receive_buffer_size
asio::socket_base::receive_low_watermark
asio::socket_base::reuse_address
asio::socket_base::send_buffer_size
asio::socket_base::send_low_watermark
asio::ip::multicast::join_group
asio::ip::multicast::leave_group
asio::ip::multicast::enable_loopback
asio::ip::multicast::outbound_interface
asio::ip::multicast::hops
asio::ip::tcp::no_delay
Example
Getting the value of the SOL_SOCKET/SO_KEEPALIVE option:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::ip::tcp::socket::keep_alive option;
 asio::error_code ec;
 socket.get_option(option, ec);
 if (ec)
 {
   // An error occurred.
 }
 bool is_set = option.get();

Definition at line 818 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename GettableSocketOption >
void asio::basic_socket< Protocol, SocketService >::get_option ( GettableSocketOption &  option  )  const [inline]

Get an option from the socket.

This function is used to get the current value of an option on the socket.

Parameters:
option The option value to be obtained from the socket.
Exceptions:
asio::system_error Thrown on failure.
See also:
GettableSocketOption
asio::socket_base::broadcast
asio::socket_base::do_not_route
asio::socket_base::keep_alive
asio::socket_base::linger
asio::socket_base::receive_buffer_size
asio::socket_base::receive_low_watermark
asio::socket_base::reuse_address
asio::socket_base::send_buffer_size
asio::socket_base::send_low_watermark
asio::ip::multicast::join_group
asio::ip::multicast::leave_group
asio::ip::multicast::enable_loopback
asio::ip::multicast::outbound_interface
asio::ip::multicast::hops
asio::ip::tcp::no_delay
Example
Getting the value of the SOL_SOCKET/SO_KEEPALIVE option:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::ip::tcp::socket::keep_alive option;
 socket.get_option(option);
 bool is_set = option.get();

Definition at line 770 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename IoControlCommand >
asio::error_code asio::basic_socket< Protocol, SocketService >::io_control ( IoControlCommand &  command,
asio::error_code ec 
) [inline]

Perform an IO control command on the socket.

This function is used to execute an IO control command on the socket.

Parameters:
command The IO control command to be performed on the socket.
ec Set to indicate what error occurred, if any.
See also:
IoControlCommand
asio::socket_base::bytes_readable
asio::socket_base::non_blocking_io
Example
Getting the number of bytes ready to read:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::ip::tcp::socket::bytes_readable command;
 asio::error_code ec;
 socket.io_control(command, ec);
 if (ec)
 {
   // An error occurred.
 }
 std::size_t bytes_readable = command.get();

Definition at line 882 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename IoControlCommand >
void asio::basic_socket< Protocol, SocketService >::io_control ( IoControlCommand &  command  )  [inline]

Perform an IO control command on the socket.

This function is used to execute an IO control command on the socket.

Parameters:
command The IO control command to be performed on the socket.
Exceptions:
asio::system_error Thrown on failure.
See also:
IoControlCommand
asio::socket_base::bytes_readable
asio::socket_base::non_blocking_io
Example
Getting the number of bytes ready to read:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::ip::tcp::socket::bytes_readable command;
 socket.io_control(command);
 std::size_t bytes_readable = command.get();

Definition at line 847 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
bool asio::basic_socket< Protocol, SocketService >::is_open (  )  const [inline]

Determine whether the socket is open.

Definition at line 233 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
endpoint_type asio::basic_socket< Protocol, SocketService >::local_endpoint ( asio::error_code ec  )  const [inline]

Get the local endpoint of the socket.

This function is used to obtain the locally bound endpoint of the socket.

Parameters:
ec Set to indicate what error occurred, if any.
Returns:
An object that represents the local endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.
Example
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::error_code ec;
 asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 932 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
endpoint_type asio::basic_socket< Protocol, SocketService >::local_endpoint (  )  const [inline]

Get the local endpoint of the socket.

This function is used to obtain the locally bound endpoint of the socket.

Returns:
An object that represents the local endpoint of the socket.
Exceptions:
asio::system_error Thrown on failure.
Example

Definition at line 903 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
lowest_layer_type& asio::basic_socket< Protocol, SocketService >::lowest_layer (  )  [inline]

Get a reference to the lowest layer.

This function returns a reference to the lowest layer in a stack of layers. Since a basic_socket cannot contain any further layers, it simply returns a reference to itself.

Returns:
A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.

Definition at line 147 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
native_type asio::basic_socket< Protocol, SocketService >::native (  )  [inline]

Get the native socket representation.

This function may be used to obtain the underlying representation of the socket. This is intended to allow access to native socket functionality that is not otherwise provided.

Definition at line 290 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::open ( const protocol_type protocol,
asio::error_code ec 
) [inline]

Open the socket using the specified protocol.

This function opens the socket so that it will use the specified protocol.

Parameters:
protocol An object specifying which protocol is to be used.
ec Set to indicate what error occurred, if any.
Example
 asio::ip::tcp::socket socket(io_service);
 asio::error_code ec;
 socket.open(asio::ip::tcp::v4(), ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 192 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::open ( const protocol_type protocol = protocol_type()  )  [inline]

Open the socket using the specified protocol.

This function opens the socket so that it will use the specified protocol.

Parameters:
protocol An object specifying protocol parameters to be used.
Exceptions:
asio::system_error Thrown on failure.
Example

Definition at line 166 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
endpoint_type asio::basic_socket< Protocol, SocketService >::remote_endpoint ( asio::error_code ec  )  const [inline]

Get the remote endpoint of the socket.

This function is used to obtain the remote endpoint of the socket.

Parameters:
ec Set to indicate what error occurred, if any.
Returns:
An object that represents the remote endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.
Example
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::error_code ec;
 asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 981 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
endpoint_type asio::basic_socket< Protocol, SocketService >::remote_endpoint (  )  const [inline]

Get the remote endpoint of the socket.

This function is used to obtain the remote endpoint of the socket.

Returns:
An object that represents the remote endpoint of the socket.
Exceptions:
asio::system_error Thrown on failure.
Example

Definition at line 952 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename SettableSocketOption >
asio::error_code asio::basic_socket< Protocol, SocketService >::set_option ( const SettableSocketOption &  option,
asio::error_code ec 
) [inline]

Set an option on the socket.

This function is used to set an option on the socket.

Parameters:
option The new option value to be set on the socket.
ec Set to indicate what error occurred, if any.
See also:
SettableSocketOption
asio::socket_base::broadcast
asio::socket_base::do_not_route
asio::socket_base::keep_alive
asio::socket_base::linger
asio::socket_base::receive_buffer_size
asio::socket_base::receive_low_watermark
asio::socket_base::reuse_address
asio::socket_base::send_buffer_size
asio::socket_base::send_low_watermark
asio::ip::multicast::join_group
asio::ip::multicast::leave_group
asio::ip::multicast::enable_loopback
asio::ip::multicast::outbound_interface
asio::ip::multicast::hops
asio::ip::tcp::no_delay
Example
Setting the IPPROTO_TCP/TCP_NODELAY option:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::ip::tcp::no_delay option(true);
 asio::error_code ec;
 socket.set_option(option, ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 728 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
template<typename SettableSocketOption >
void asio::basic_socket< Protocol, SocketService >::set_option ( const SettableSocketOption &  option  )  [inline]
template<typename Protocol, typename SocketService>
asio::error_code asio::basic_socket< Protocol, SocketService >::shutdown ( shutdown_type  what,
asio::error_code ec 
) [inline]

Disable sends or receives on the socket.

This function is used to disable send operations, receive operations, or both.

Parameters:
what Determines what types of operation will no longer be allowed.
ec Set to indicate what error occurred, if any.
Example
Shutting down the send side of the socket:
 asio::ip::tcp::socket socket(io_service);
 ...
 asio::error_code ec;
 socket.shutdown(asio::ip::tcp::socket::shutdown_send, ec);
 if (ec)
 {
   // An error occurred.
 }

Definition at line 1032 of file basic_socket.hpp.

template<typename Protocol, typename SocketService>
void asio::basic_socket< Protocol, SocketService >::shutdown ( shutdown_type  what  )  [inline]

Disable sends or receives on the socket.

This function is used to disable send operations, receive operations, or both.

Parameters:
what Determines what types of operation will no longer be allowed.
Exceptions:
asio::system_error Thrown on failure.
Example
Shutting down the send side of the socket:

Definition at line 1003 of file basic_socket.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Castor
Author(s): Carpe Noctem
autogenerated on Fri Mar 1 14:41:41 2013