blob: 4a1055e450203dae0a71a0a7221539eb6b808bb2 [file] [log] [blame]
Ravi Tejace1c96f2020-10-05 23:13:01 -05001#pragma once
2
Andrew Jefferyda4b13c2023-04-28 12:56:20 +09303#include <cstdint>
Ravi Tejace1c96f2020-10-05 23:13:01 -05004#include <string>
5
6namespace pldm
7{
8namespace responder
9{
10namespace 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 */
22int 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 */
36int writeToUnixSocket(const int sock, const char* buf,
37 const uint64_t blockSize);
38} // namespace utils
39} // namespace responder
40} // namespace pldm