The socket class.  
 More...
#include <socket.h>
The socket class. 
Definition at line 35 of file socket.h.
  
  | 
        
          | tasks::net::socket::socket | ( | int | fd | ) |  |  | inline | 
 
Constructor
- Parameters
- 
  
    | fd | Use fd for the socket object. |  
 
Definition at line 40 of file socket.h.
 
 
Constructor
- Parameters
- 
  
  
Definition at line 23 of file socket.cpp.
 
 
      
        
          | socket tasks::net::socket::accept | ( |  | ) |  | 
      
 
Accept new client connections. 
Definition at line 136 of file socket.cpp.
 
 
  
  | 
        
          | std::shared_ptr<struct sockaddr_in> tasks::net::socket::addr | ( |  | ) |  |  | inline | 
 
- Returns
- A pointer to the sockaddr_in struct. 
Definition at line 58 of file socket.h.
 
 
      
        
          | void tasks::net::socket::bind | ( | int | port, | 
        
          |  |  | std::string | ip = "" | 
        
          |  | ) |  |  | 
      
 
 
  
  | 
        
          | void tasks::net::socket::bind | ( | int | port, |  
          |  |  | std::string | ip, |  
          |  |  | bool | udp |  
          |  | ) |  |  |  | private | 
 
 
      
        
          | void tasks::net::socket::connect | ( | std::string | path | ) |  | 
      
 
Connect to a domain socket.
- Parameters
- 
  
    | path | The path to the socket file. |  
 
Definition at line 147 of file socket.cpp.
 
 
      
        
          | void tasks::net::socket::connect | ( | std::string | host, | 
        
          |  |  | int | port | 
        
          |  | ) |  |  | 
      
 
Connect via tcp.
- Parameters
- 
  
    | host | The hostname or ip address in dot notation. |  | port | The port. |  
 
Definition at line 185 of file socket.cpp.
 
 
  
  | 
        
          | void tasks::net::socket::init_sockaddr | ( | int | port, |  
          |  |  | std::string | ip = "" |  
          |  | ) |  |  |  | private | 
 
 
      
        
          | void tasks::net::socket::listen | ( | std::string | path, | 
        
          |  |  | int | queue_size = 128 | 
        
          |  | ) |  |  | 
      
 
Listen for unix domain sockets.
- Parameters
- 
  
    | path | The path to the socket file. |  | queue_size | The liste queue size. The default value is 128. |  
 
Definition at line 36 of file socket.cpp.
 
 
      
        
          | void tasks::net::socket::listen | ( | int | port, | 
        
          |  |  | std::string | ip = "", | 
        
          |  |  | int | queue_size = 128 | 
        
          |  | ) |  |  | 
      
 
- Parameters
- 
  
    | port | The port. |  | ip | The ip address in dot notation (optional). |  | queue_size | The liste queue size. The default value is 128. |  
 
Definition at line 76 of file socket.cpp.
 
 
      
        
          | std::streamsize tasks::net::socket::read | ( | char * | data, | 
        
          |  |  | std::size_t | len | 
        
          |  | ) |  |  | 
      
 
Read data from a socket.
- Parameters
- 
  
    | data | A pointer to the destination data. |  | len | The number of bytes to write. |  
 
Definition at line 251 of file socket.cpp.
 
 
  
  | 
        
          | void tasks::net::socket::set_blocking | ( |  | ) |  |  | inline | 
 
Set the socket to blocking mode. 
Definition at line 61 of file socket.h.
 
 
      
        
          | void tasks::net::socket::shutdown | ( |  | ) |  | 
      
 
Call shutdown on the fd. 
Definition at line 218 of file socket.cpp.
 
 
  
  | 
        
          | bool tasks::net::socket::tcp | ( |  | ) | const |  | inline | 
 
 
- Returns
- The the socket type. 
Definition at line 55 of file socket.h.
 
 
  
  | 
        
          | bool tasks::net::socket::udp | ( |  | ) | const |  | inline | 
 
 
      
        
          | std::streamsize tasks::net::socket::write | ( | const char * | data, | 
        
          |  |  | std::size_t | len, | 
        
          |  |  | int | port = -1, | 
        
          |  |  | std::string | ip = "" | 
        
          |  | ) |  |  | 
      
 
Write data to the socket.
- Parameters
- 
  
    | data | A pointer to the source data. |  | len | The number of bytes to write. |  | port | As UDP sockets are not connection based, the remote port has to be passed. |  | ip | Optional ip in dot notation for UDP writes. |  
 
Definition at line 225 of file socket.cpp.
 
 
  
  | 
        
          | std::shared_ptr<struct sockaddr_in> tasks::net::socket::m_addr |  | private | 
 
 
  
  | 
        
          | bool tasks::net::socket::m_blocking = false |  | private | 
 
 
The documentation for this class was generated from the following files: