forked from FISCO-BCOS/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not expect a new line, rather buffer up the response in IPC
- Loading branch information
Showing
2 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
/** @file RPCSession.cpp | ||
* @author Dimtiry Khokhlov <[email protected]> | ||
* @author Alex Beregszaszi | ||
* @date 2016 | ||
*/ | ||
|
||
|
@@ -91,18 +92,17 @@ string IPCSocket::sendRequest(string const& _req) | |
if (!fSuccess) | ||
BOOST_FAIL("WriteFile to pipe failed"); | ||
|
||
DWORD cbRead; | ||
TCHAR chBuf[c_buffsize]; | ||
DWORD cbRead; | ||
|
||
// Read from the pipe. | ||
fSuccess = ReadFile( | ||
m_socket, // pipe handle | ||
chBuf, // buffer to receive reply | ||
c_buffsize,// size of buffer | ||
&cbRead, // number of bytes read | ||
NULL); // not overlapped | ||
m_socket, // pipe handle | ||
m_readBuf, // buffer to receive reply | ||
sizeof(m_readBuf), // size of buffer | ||
&cbRead, // number of bytes read | ||
NULL); // not overlapped | ||
|
||
returnStr += chBuf; | ||
returnStr += m_readBuf; | ||
|
||
if (!fSuccess) | ||
BOOST_FAIL("ReadFile from pipe failed"); | ||
|
@@ -112,16 +112,12 @@ string IPCSocket::sendRequest(string const& _req) | |
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 (recv(m_socket, &c, 1, 0) == 1) | ||
{ | ||
if (c != '\n') | ||
response += c; | ||
else | ||
break; | ||
} | ||
return response; | ||
ssize_t ret = recv(m_socket, m_readBuf, sizeof(m_readBuf), 0); | ||
|
||
if (ret < 0) | ||
BOOST_FAIL("Reading on IPC failed"); | ||
|
||
return string(m_readBuf, m_readBuf + ret); | ||
#endif | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters