Open summerlotus513 opened 1 year ago
我怀疑是socket的close导致的问题:
https://stackoverflow.com/questions/7732726/bad-file-descriptor-closing-boost-socket
按照上述的说法,似乎不应该手动调用socket的close方法?
而且,在每次调用完成后,使用netstat -nat | grep 9000
查看,发现连接仍然存在,未被关闭。
用的最新代码测试的吗? linux还是windowx下测试的? 我用这个代码在mac下测了一下。
server输出:
remote client address: 127.0.0.1 networking error, reason: End of file
hello rest_rpc
remote client address: 127.0.0.1 networking error, reason: End of file
client 输出:
connected ok
End of file
这个输出是正常的。 client请求完之后会关闭连接,所以会打印出eof; client断开之后server也会关闭对应的client的socket,同样会打印eof。
我这里在linux上客户端在远程调用后也是遇到这个提示: Operation aborted.
用的最新的代码,启用这个宏:MSGPACK_NO_BOOST;
代码比较简单:
try {
rpc_client client("127.0.0.1", 9000);
bool r = client.connect(3);
if (!r) {
return -1;
}
auto result = client.call<std::string>("forward-args", sArgStr);
std::cout << "forward-args ret:" << result << std::endl;
}
catch (const std::exception& e) {
return -1;
}
catch (const std::out_of_range& e) {
return -1;
}
catch (...) {
return -1;
}
最简单的rest_rpc demo server
client
报错信息如下: server
client
当我吧asio更新至最新后,段错误便不会出现了,但是依然有Operation aborted的错误