We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
客户端代码:
#include "handy/ssl-conn.h"
int main(int argc, const char* argv[]) { using namespace handy; Logger::getLogger().setLogLevel(Logger::LTRACE); EventBase ebase; Signal::signal(SIGINT, [&]{ ebase.exit(); }); SSLConn::setSSLCertKey("server.pem", "server.pem"); TcpServer ss(&ebase); int r = ss.bind("0.0.0.0", 1002); exitif(r, "bind failed %d %s", errno, strerror(errno)); ss.onConnCreate([]{ return TcpConnPtr(new SSLConn); }); ss.onConnRead([](const TcpConnPtr& con) { con->send(con->getInput()); con->getInput().clear(); }); ebase.loop(); return 0; }
服务端代码:
int main(int argc, const char* argv[]) { Logger::getLogger().setLogLevel(Logger::LTRACE); EventBase ebase; Signal::signal(SIGINT, [&]{ ebase.exit(); }); SSLConn::setSSLCertKey("server.pem", "server.pem"); TcpServer ss(&ebase); int r = ss.bind("0.0.0.0", 1002); exitif(r, "bind failed %d %s", errno, strerror(errno)); ss.onConnCreate([]{ return TcpConnPtr(new SSLConn); }); ss.onConnRead([](const TcpConnPtr& con) { con->send(con->getInput()); con->getInput().clear(); });
TcpServer ts(&ebase); r = ts.bind("0.0.0.0", 1003); exitif(r, "bind failed %d %s", errno, strerror(errno)); ts.onConnRead([](const TcpConnPtr& con) { con->send(con->getInput()); con->getInput().clear(); }); ebase.loop(); return 0;
}
问题大致的原因是服务端关掉重启后,服务端的SSlconn已经重新new了,但是客户端的sslconn还是原来的,客户重连上来虽然显示成功了,但并没有重新握手。也就导致服务端收不到有连接进来的消息。
The text was updated successfully, but these errors were encountered:
您这边客户端需要处理好连接断开的情况。handy-ssl里的例子主要是演示ssl连接的基本功能,没包括断开重新创建对象并连接这部分
Sorry, something went wrong.
No branches or pull requests
客户端代码:
#include "handy/ssl-conn.h"
int main(int argc, const char* argv[]) {
using namespace handy;
Logger::getLogger().setLogLevel(Logger::LTRACE);
EventBase ebase;
Signal::signal(SIGINT, [&]{ ebase.exit(); });
SSLConn::setSSLCertKey("server.pem", "server.pem");
TcpServer ss(&ebase);
int r = ss.bind("0.0.0.0", 1002);
exitif(r, "bind failed %d %s", errno, strerror(errno));
ss.onConnCreate([]{ return TcpConnPtr(new SSLConn); });
ss.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
con->getInput().clear();
});
ebase.loop();
return 0;
}
服务端代码:
#include "handy/ssl-conn.h"
int main(int argc, const char* argv[]) {
Logger::getLogger().setLogLevel(Logger::LTRACE);
EventBase ebase;
Signal::signal(SIGINT, [&]{ ebase.exit(); });
SSLConn::setSSLCertKey("server.pem", "server.pem");
TcpServer ss(&ebase);
int r = ss.bind("0.0.0.0", 1002);
exitif(r, "bind failed %d %s", errno, strerror(errno));
ss.onConnCreate([]{ return TcpConnPtr(new SSLConn); });
ss.onConnRead([](const TcpConnPtr& con) {
con->send(con->getInput());
con->getInput().clear();
});
}
问题大致的原因是服务端关掉重启后,服务端的SSlconn已经重新new了,但是客户端的sslconn还是原来的,客户重连上来虽然显示成功了,但并没有重新握手。也就导致服务端收不到有连接进来的消息。
The text was updated successfully, but these errors were encountered: