We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8116593 commit 4978ea7Copy full SHA for 4978ea7
src/impl/tcpserver.cpp
@@ -66,8 +66,12 @@ shared_ptr<TcpTransport> TcpServer::accept() {
66
socket_t incomingSock = ::accept(mSock, (struct sockaddr *)&addr, &addrlen);
67
68
if (incomingSock != INVALID_SOCKET) {
69
- return std::make_shared<TcpTransport>(incomingSock, nullptr); // no state callback
70
-
+ try {
+ return std::make_shared<TcpTransport>(incomingSock, nullptr); // no state callback
71
+ } catch(const std::exception &e) {
72
+ PLOG_WARNING << e.what();
73
+ ::closesocket(incomingSock);
74
+ }
75
} else if (sockerrno != SEAGAIN && sockerrno != SEWOULDBLOCK) {
76
PLOG_ERROR << "TCP server failed, errno=" << sockerrno;
77
throw std::runtime_error("TCP server failed");
0 commit comments