Skip to content

Commit

Permalink
Use only send/recv in IPC
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 9, 2017
1 parent 1b7bb37 commit b508aac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
9 changes: 3 additions & 6 deletions test/RPCSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ IPCSocket::IPCSocket(string const& _path): m_path(_path)

if (connect(m_socket, reinterpret_cast<struct sockaddr const*>(&saun), sizeof(struct sockaddr_un)) < 0)
BOOST_FAIL("Error connecting to IPC socket: " << _path);

m_fp = fdopen(m_socket, "r");
if (!m_fp)
BOOST_FAIL("Error opening IPC socket: " << _path);
#endif
}

Expand Down Expand Up @@ -113,11 +109,12 @@ string IPCSocket::sendRequest(string const& _req)

return returnStr;
#else
send(m_socket, _req.c_str(), _req.length(), 0);
if (send(m_socket, _req.c_str(), _req.length(), 0) != (ssize_t)_req.length())
BOOST_FAIL("Writing on IPC failed");

char c;
string response;
while ((c = fgetc(m_fp)) != EOF)
while (recv(m_socket, &c, 1, 0) == 1)
{
if (c != '\n')
response += c;
Expand Down
3 changes: 1 addition & 2 deletions test/RPCSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ class IPCSocket: public boost::noncopyable
public:
IPCSocket(std::string const& _path);
std::string sendRequest(std::string const& _req);
~IPCSocket() { close(m_socket); fclose(m_fp); }
~IPCSocket() { close(m_socket); }

std::string const& path() const { return m_path; }

private:
FILE *m_fp;
std::string m_path;
int m_socket;
};
Expand Down

0 comments on commit b508aac

Please sign in to comment.