#include <basic_socket.h>
Public Types | |
| typedef sockets_base::socket_type | descriptor_t | 
| This is the type of a socket descriptor on the system.   | |
Public Member Functions | |
| basic_socket () | |
| Default constructor.   | |
| basic_socket (int __family, int __style, int __protocol=0) | |
| Constructor.   | |
| basic_socket (descriptor_t __sd) | |
| Constructor for an existing socket descriptor.   | |
| ~basic_socket () | |
| void | bind (sockaddr const *__addr, socklen_t __size) | 
| Bind socket to local address.   | |
| void | connect (sockaddr const *__addr, socklen_t __size) | 
| Connect socket to remote address.   | |
| void | listen (int __backlog=5) | 
| Listen to incoming connections.   | |
| descriptor_t | accept () | 
| Accept incoming connection.   | |
| int | receive (char *__s, size_t __n, int __flags=0) | 
| Receive data on connected socket.   | |
| int | receive (char *__s, size_t __n, sockaddr *__addr, socklen_t *__size, int __flags=0) | 
| Receive data on connectionless socket.   | |
| int | send (const char *__s, size_t __n, int __flags=0) | 
| Send data on connected socket.   | |
| int | send (const char *__s, size_t __n, sockaddr const *__addr, socklen_t __size, int __flags=0) | 
| Send data on connectionless socket.   | |
| void | set_option (int __level, int __option, char const *__value, socklen_t __size) | 
| Set socket option.   | |
| void | get_option (int __level, int __option, char *__value, socklen_t *__size) const | 
| Get socket option.   | |
| void | shutdown (int __mode=sockets_base::rw) | 
| Shut the socket down.   | |
| void | peer_address (sockaddr *__name, socklen_t *__size) const | 
| Peer address.   | |
| void | socket_address (sockaddr *__name, socklen_t *__size) const | 
| Socket address.   | |
| descriptor_t | descriptor () const | 
| Socket descriptor.   | |
Friends | |
| class | basic_socketbuf | 
This class implements "resource acquisition is initialization" for socket descriptors.
The purpose of this class is to merely wrap the C socket API (effectively, to wrap the socket descriptor). Thus, it's member function prototypes follow closely those of the C API, and no error treatment other than the trivial is done.
The only big departure from the C API is the fact that error conditions intercepted are thrown as socket_exception objects containing the error code from std::errno. Thus, almost all functions now return void.
Also, the return type of the accept method is basic_socket, instead of the descriptor type.
All I/O operations are considered non-const operations; setsockopt is also considered non-const for obvious reasons. getsockopt, getpeername, getsockname, and all "properties" are considered const operations.
Definition at line 57 of file basic_socket.h.
      
  | 
  
| 
 This is the type of a socket descriptor on the system. This is usually int, but don't count on it unless you're Unix-only. Definition at line 66 of file basic_socket.h.  | 
  
      
  | 
  
| 
 Default constructor. Socket's constructor wraps the socket() system call, which allocates a socket descriptor in the system for this process. This constructor will create a socket of default family and style, currently sockets_base::inet and sockets_base::stream.  | 
  
      
  | 
  ||||||||||||||||
| 
 Constructor. 
 
 Constructs socket of specified family, style and protocol. We usually use a default protocol.  | 
  
      
  | 
  
| 
 Constructor for an existing socket descriptor. 
 
 basic_socket takes ownership of the descriptor, and will close it at destruction time. Particularly useful with basic_socket::accept().  | 
  
      
  | 
  
| 
 Destructor.  | 
  
      
  | 
  
| 
 Accept incoming connection. 
 
 Referenced by ss::basic_listener< _CharT, _Traits >::accept().  | 
  
      
  | 
  ||||||||||||
| 
 Bind socket to local address. 
 
 Referenced by ss::basic_listener< _CharT, _Traits >::bind().  | 
  
      
  | 
  ||||||||||||
| 
 Connect socket to remote address. 
 
 Referenced by ss::basic_socketbuf< char_type, traits_type >::connect().  | 
  
      
  | 
  
| 
 Socket descriptor. 
 
 Definition at line 287 of file basic_socket.h.  | 
  
      
  | 
  ||||||||||||||||||||
| 
 Get socket option. 
 
  | 
  
      
  | 
  
| 
 Listen to incoming connections. 
 
 This is the opposite of connect(), so to speak, and is only truly meaningful for stream sockets. Referenced by ss::basic_listener< _CharT, _Traits >::listen().  | 
  
      
  | 
  ||||||||||||
| 
 Peer address. 
 
  | 
  
      
  | 
  ||||||||||||||||||||||||
| 
 Receive data on connectionless socket. 
 
 
  | 
  
      
  | 
  ||||||||||||||||
| 
 Receive data on connected socket. 
 
 
 Referenced by ss::basic_socketbuf< char_type, traits_type >::showmanyc(), and ss::basic_socketbuf< char_type, traits_type >::underflow().  | 
  
      
  | 
  ||||||||||||||||||||||||
| 
 Send data on connectionless socket. 
 
 
  | 
  
      
  | 
  ||||||||||||||||
| 
 Send data on connected socket. 
 
 
 Referenced by ss::basic_socketbuf< char_type, traits_type >::overflow().  | 
  
      
  | 
  ||||||||||||||||||||
| 
 Set socket option. 
 
  | 
  
      
  | 
  
| 
 Shut the socket down. 
 
 Referenced by ss::basic_socketbuf< char_type, traits_type >::shutdown().  | 
  
      
  | 
  ||||||||||||
| 
 Socket address. 
 
  | 
  
 1.4.3