Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Jeffery | da4b13c | 2023-04-28 12:56:20 +0930 | [diff] [blame^] | 3 | #include <cstdint> |
Ravi Teja | ce1c96f | 2020-10-05 23:13:01 -0500 | [diff] [blame] | 4 | #include <string> |
| 5 | |
| 6 | namespace pldm |
| 7 | { |
| 8 | namespace responder |
| 9 | { |
| 10 | namespace utils |
| 11 | { |
| 12 | |
| 13 | /** @brief Setup UNIX socket |
| 14 | * This function creates listening socket in non-blocking mode and allows only |
| 15 | * one socket connection. returns accepted socket after accepting connection |
| 16 | * from peer. |
| 17 | * |
| 18 | * @param[in] socketInterface - unix socket path |
| 19 | * @return on success returns accepted socket fd |
| 20 | * on failure returns -1 |
| 21 | */ |
| 22 | int setupUnixSocket(const std::string& socketInterface); |
| 23 | |
| 24 | /** @brief Write data on UNIX socket |
| 25 | * This function writes given data to a non-blocking socket. |
| 26 | * Irrespective of block size, this function make sure of writing given data |
| 27 | * on unix socket. |
| 28 | * |
| 29 | * @param[in] sock - unix socket |
| 30 | * @param[in] buf - data buffer |
| 31 | * @param[in] blockSize - size of data to write |
| 32 | * @return on success retruns 0 |
| 33 | * on failure returns -1 |
| 34 | |
| 35 | */ |
| 36 | int writeToUnixSocket(const int sock, const char* buf, |
| 37 | const uint64_t blockSize); |
| 38 | } // namespace utils |
| 39 | } // namespace responder |
| 40 | } // namespace pldm |