forked from ethereum/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.
- Loading branch information
Showing
6 changed files
with
176 additions
and
35 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 |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
You should have received a copy of the GNU General Public License | ||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
The Implementation originally from https://msdn.microsoft.com/en-us/library/windows/desktop/aa365592(v=vs.85).aspx | ||
*/ | ||
/** @file RPCSession.cpp | ||
* @author Dimtiry Khokhlov <[email protected]> | ||
|
@@ -32,6 +34,19 @@ using namespace dev; | |
|
||
IPCSocket::IPCSocket(string const& _path): m_path(_path) | ||
{ | ||
m_socket = CreateFile( | ||
m_path.c_str(), // pipe name | ||
GENERIC_READ | // read and write access | ||
GENERIC_WRITE, | ||
0, // no sharing | ||
NULL, // default security attribute | ||
OPEN_EXISTING, // opens existing pipe | ||
0, // default attributes | ||
NULL); // no template file | ||
|
||
if (m_socket == INVALID_HANDLE_VALUE) | ||
BOOST_FAIL("Error creating IPC socket object"); | ||
|
||
#if defined(_WIN32) | ||
#else | ||
if (_path.length() >= sizeof(sockaddr_un::sun_path)) | ||
|
@@ -66,7 +81,36 @@ IPCSocket::IPCSocket(string const& _path): m_path(_path) | |
string IPCSocket::sendRequest(string const& _req) | ||
{ | ||
#if defined(_WIN32) | ||
return ""; | ||
string returnStr; | ||
DWORD cbWritten; | ||
BOOL fSuccess = WriteFile( | ||
m_socket, // pipe handle | ||
_req.c_str(), // message | ||
_req.size(), // message length | ||
&cbWritten, // bytes written | ||
NULL); // not overlapped | ||
|
||
if (!fSuccess) | ||
BOOST_FAIL("WriteFile to pipe failed"); | ||
|
||
DWORD cbRead; | ||
TCHAR chBuf[c_buffsize]; | ||
|
||
// 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 | ||
|
||
returnStr += chBuf; | ||
|
||
if (!fSuccess) | ||
BOOST_FAIL("ReadFile from pipe failed"); | ||
|
||
cerr << "."; //Output for log activity | ||
return returnStr; | ||
#else | ||
send(m_socket, _req.c_str(), _req.length(), 0); | ||
|
||
|
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
This file is part of cpp-ethereum. | ||
cpp-ethereum is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
cpp-ethereum is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** @file TestHelper.h | ||
* @author Marko Simovic <[email protected]> | ||
* @date 2014 | ||
*/ | ||
|
||
#include <boost/test/framework.hpp> | ||
#include "TestHelper.h" | ||
using namespace std; | ||
using namespace dev::test; | ||
|
||
Options::Options(int argc, char** argv) | ||
{ | ||
tArgc = 0; | ||
tArgv = new char*[argc]; | ||
for (size_t i = 0; i < argc; i++) | ||
{ | ||
string arg = argv[i]; | ||
if (arg == "--ipc" && i + 1 < argc) | ||
{ | ||
ipcPath = argv[i + 1]; | ||
i++; | ||
} | ||
else | ||
{ | ||
tArgv[i] = argv[i]; | ||
tArgc++; | ||
} | ||
} | ||
} | ||
|
||
Options const& Options::get(int argc, char** argv) | ||
{ | ||
static Options instance(argc, argv); | ||
return instance; | ||
} |
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
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
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