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