Skip to content

Commit 62862a3

Browse files
author
caozhiyi
committed
debug rpc on linux.
1 parent 7847b8f commit 62862a3

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

test/rpc/ParsePackage.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ bool CParsePackage::ParseType(char* buf, int len, int& type) {
2424
return false;
2525
}
2626

27-
char typec[1];
27+
char typec[4] = { 0 };
2828
memcpy(typec, buf, 1);
2929
type = atoi(typec);
30-
3130
return true;
3231
}
3332

test/rpc/RPCClient.h

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#ifndef TEST_RPC_RPCCLIENT_HEADER
22
#define TEST_RPC_RPCCLIENT_HEADER
33

4-
#include <memory>
5-
6-
#include <iostream>
7-
84
#include "CppDefine.h"
95
#include "Socket.h"
106
#include "CommonStruct.h"

test/rpc/RPCServer.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "CppNet.h"
77
#include "CommonStruct.h"
88

9-
#include <iostream>
10-
119
CRPCServer::CRPCServer() : _info_router(new CInfoRouter), _parse_package(new CParsePackage), _pool(1024, 5), _need_mutex(false){
1210

1311
}

test/rpc/TestClient.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
using namespace std;
66

77
void Add1CallBack(int code, std::vector<base::CAny>& ret) {
8-
if (code == NO_ERROR) {
8+
if (code == NO_ERROR) {
99
cout << code << " " << base::any_cast<int>(ret[0]) << endl;
10-
}
10+
}
1111
}
1212

1313
Call_back func = Add1CallBack;
1414

1515
int main() {
16-
CRPCClient client;
16+
CRPCClient client;
1717
client.SetCallBack("Add1", func);
1818
client.Start(8951, "127.0.0.1");
19-
for (;;) {
19+
for (;;) {
2020
base::CRunnable::Sleep(1000);
2121
client.CallFunc("Add1", 100, 200);
22-
}
22+
}
2323
}

0 commit comments

Comments
 (0)