* @brief Send data to connected socket * * @param buf Pointer to the data * @param len The length of the buffer * @param flags Flags for `send(2)` * * @retval n *n* bytes were sent * @retval <0 An error occurred. */
| 133 | * @retval <0 An error occurred. |
| 134 | */ |
| 135 | ssize_t dgram_client_socket::snd(const void* buf, size_t len, int flags) { |
| 136 | ssize_t bytes; |
| 137 | |
| 138 | if (connected != true) |
| 139 | throw socket_exception( |
| 140 | __FILE__, __LINE__, |
| 141 | "dgram_client_socket::snd() - Socket is not connected!", false); |
| 142 | |
| 143 | if (-1 == (bytes = send(sfd, buf, len, flags))) |
| 144 | throw socket_exception(__FILE__, __LINE__, |
| 145 | "dgram_client_socket::snd() - send() failed!"); |
| 146 | |
| 147 | return bytes; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * @brief Send data to connected peer |
no test coverage detected