1 #pragma once
2 
3 #include <string>
4 
5 namespace pldm
6 {
7 namespace responder
8 {
9 namespace 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  */
21 int 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  */
35 int writeToUnixSocket(const int sock, const char* buf,
36                       const uint64_t blockSize);
37 } // namespace utils
38 } // namespace responder
39 } // namespace pldm
40