Skip to content

Commit

Permalink
Merge pull request #256 from MarvinParanoid/master
Browse files Browse the repository at this point in the history
Fix for TCP connector for Win
  • Loading branch information
cinemast authored Jan 28, 2019
2 parents 5da6006 + c23ba28 commit 0201ebb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/jsonrpccpp/client/connectors/tcpsocketclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "tcpsocketclient.h"

#ifdef __WIN32__
#ifdef _WIN32
#include "windowstcpsocketclient.h"
#else
#include "linuxtcpsocketclient.h"
Expand All @@ -20,7 +20,7 @@ using namespace std;

TcpSocketClient::TcpSocketClient(const std::string &ipToConnect,
const unsigned int &port) {
#ifdef __WIN32__
#ifdef _WIN32
this->realSocket = new WindowsTcpSocketClient(ipToConnect, port);
#else
this->realSocket = new LinuxTcpSocketClient(ipToConnect, port);
Expand Down
4 changes: 2 additions & 2 deletions src/jsonrpccpp/client/connectors/windowstcpsocketclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ SOCKET WindowsTcpSocketClient::Connect() throw(JsonRpcException) {
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
char port[6];
port = itoa(this->port, port, 10);
char port[6];
itoa(this->port, port, 10);
DWORD retval =
getaddrinfo(this->hostToConnect.c_str(), port, &hints, &result);
if (retval != 0)
Expand Down
4 changes: 3 additions & 1 deletion src/jsonrpccpp/server/connectors/windowstcpsocketserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ DWORD WINAPI WindowsTcpSocketServer::GenerateResponse(LPVOID lp_data) {
request.append(buffer, nbytes);
}
} while (request.find(DELIMITER_CHAR) == string::npos);
instance->OnRequest(request, reinterpret_cast<void *>(connection_fd));
std::string response;
instance->ProcessRequest(request, response);
instance->SendResponse(response, reinterpret_cast<void *>(connection_fd));
CloseHandle(GetCurrentThread());
return 0; // DO NOT USE ExitThread function here! ExitThread does not call
// destructors for allocated objects and therefore it would lead to
Expand Down

0 comments on commit 0201ebb

Please sign in to comment.