asio 0.1.5 Main Page | Class Index | Member Index | Tutorial

socket_error Class Reference

The socket_error class is used to encapsulate socket error codes. More...

List of all members.

Public Types

enum  code_type {
  access_denied = ASIO_SOCKET_ERROR(EACCES),
  address_family_not_supported = ASIO_SOCKET_ERROR(EAFNOSUPPORT),
  address_in_use = ASIO_SOCKET_ERROR(EADDRINUSE),
  already_connected = ASIO_SOCKET_ERROR(EISCONN),
  already_started = ASIO_SOCKET_ERROR(EALREADY),
  connection_refused = ASIO_SOCKET_ERROR(ECONNREFUSED),
  connection_reset = ASIO_SOCKET_ERROR(ECONNRESET),
  bad_descriptor = ASIO_SOCKET_ERROR(EBADF),
  fault = ASIO_SOCKET_ERROR(EFAULT),
  host_not_found = ASIO_SOCKET_ERROR(HOST_NOT_FOUND),
  host_not_found_try_again = ASIO_SOCKET_ERROR(TRY_AGAIN),
  host_unreachable = ASIO_SOCKET_ERROR(EHOSTUNREACH),
  in_progress = ASIO_SOCKET_ERROR(EINPROGRESS),
  interrupted = ASIO_SOCKET_ERROR(EINTR),
  invalid_argument = ASIO_SOCKET_ERROR(EINVAL),
  message_size = ASIO_SOCKET_ERROR(EMSGSIZE),
  network_down = ASIO_SOCKET_ERROR(ENETDOWN),
  network_reset = ASIO_SOCKET_ERROR(ENETRESET),
  network_unreachable = ASIO_SOCKET_ERROR(ENETUNREACH),
  no_descriptors = ASIO_SOCKET_ERROR(EMFILE),
  no_buffer_space = ASIO_SOCKET_ERROR(ENOBUFS),
  no_host_data = ASIO_SOCKET_ERROR(NO_DATA),
  no_memory = ENOMEM,
  no_permission = EPERM,
  no_protocol_option = ASIO_SOCKET_ERROR(ENOPROTOOPT),
  no_recovery = ASIO_SOCKET_ERROR(NO_RECOVERY),
  not_connected = ASIO_SOCKET_ERROR(ENOTCONN),
  not_socket = ASIO_SOCKET_ERROR(ENOTSOCK),
  not_supported = ASIO_SOCKET_ERROR(EOPNOTSUPP),
  operation_aborted = ECANCELED,
  shut_down = ASIO_SOCKET_ERROR(ESHUTDOWN),
  success = 0,
  timed_out = ASIO_SOCKET_ERROR(ETIMEDOUT),
  try_again = EAGAIN,
  would_block = ASIO_SOCKET_ERROR(EWOULDBLOCK)
}
 Error codes. More...


Public Member Functions

 socket_error ()
 Default constructor.

 socket_error (int code)
 Construct with a specific error code.

int code () const
 Get the code associated with the error.

std::string message () const
 Get the message associated with the error.

 operator void * () const
 Operator returns non-null if there is a non-success error code.

bool operator! () const
 Operator to test if the error represents success.


Friends

bool operator== (const socket_error &e1, const socket_error &e2)
 Equality operator to compare two error objects.

bool operator!= (const socket_error &e1, const socket_error &e2)
 Inequality operator to compare two error objects.

std::ostream & operator<< (std::ostream &os, const socket_error &e)
 Write an error message to an output stream.


Detailed Description

The socket_error class is used to encapsulate socket error codes.


Member Enumeration Documentation

enum code_type
 

Error codes.

Enumeration values:
access_denied  Permission denied.
address_family_not_supported  Address family not supported by protocol.
address_in_use  Address already in use.
already_connected  Transport endpoint is already connected.
already_started  Operation already in progress.
connection_refused  Connection refused.
connection_reset  Connection reset by peer.
bad_descriptor  Bad file descriptor.
fault  Bad address.
host_not_found  Host not found (authoritative).
host_not_found_try_again  Host not found (non-authoritative).
host_unreachable  No route to host.
in_progress  Operation now in progress.
interrupted  Interrupted system call.
invalid_argument  Invalid argument.
message_size  Message too long.
network_down  Network is down.
network_reset  Network dropped connection on reset.
network_unreachable  Network is unreachable.
no_descriptors  Too many open files.
no_buffer_space  No buffer space available.
no_host_data  The host is valid but does not have address data.
no_memory  Cannot allocate memory.
no_permission  Operation not permitted.
no_protocol_option  Protocol not available.
no_recovery  A non-recoverable error occurred.
not_connected  Transport endpoint is not connected.
not_socket  Socket operation on non-socket.
not_supported  Operation not supported.
operation_aborted  Operation cancelled.
shut_down  Cannot send after transport endpoint shutdown.
success  Success.
timed_out  Connection timed out.
try_again  Resource temporarily unavailable.
would_block  The socket is marked non-blocking and the requested operation would block.


Constructor & Destructor Documentation

socket_error  ) 
 

Default constructor.

socket_error int  code  ) 
 

Construct with a specific error code.


Member Function Documentation

int code  )  const
 

Get the code associated with the error.

std::string message  )  const
 

Get the message associated with the error.

operator void *  )  const
 

Operator returns non-null if there is a non-success error code.

bool operator!  )  const
 

Operator to test if the error represents success.


Friends And Related Function Documentation

bool operator== const socket_error e1,
const socket_error e2
[friend]
 

Equality operator to compare two error objects.

bool operator!= const socket_error e1,
const socket_error e2
[friend]
 

Inequality operator to compare two error objects.

std::ostream& operator<< std::ostream &  os,
const socket_error e
[friend]
 

Write an error message to an output stream.