libzmq
libzmq copied to clipboard
When using inproc mode, the closure of an open socket will still affect the creation of new sockets
#include "zmq.hpp"
#include "fmt/format.h"
#include <thread>
using namespace std::chrono_literals;
int main()
{
zmq::context_t ctx;
int count = 0;
for (int i = 0; i < 3; ++i)
{
try
{
while (true)
{
zmq::socket_t sock(ctx, zmq::socket_type::pull);
sock.set(zmq::sockopt::linger, 0);
sock.connect("inproc://szn");
++count;
}
}
catch (std::exception& e)
{
fmt::print("got error: {}, count is {}\n", e.what(), count);
count = 0;
std::this_thread::sleep_for(5s);
}
}
return 0;
}
/*
got error: Too many open files, count is 1023
got error: Too many open files, count is 0
got error: Too many open files, count is 0
*/