Boost Asio File Descriptor

Hi all,

I'm using boost asio 1.45 (latest version) in my application, this is working fine but I'm having problems with "Too many open files" error.

It happens when I have no network like an unplugged cable, if my server is disconnected and I have a valid network connection, the FD is closed correctly.

I got the code from Boost examples:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
boost::asio::io_service io_service;

				boost::shared_ptr<tcp::resolver> resolver;
				tcp::resolver::query query(tcp::v4(), properties.getServer(), properties.getPort());

				boost::system::error_code errorNetwork = boost::asio::error::host_not_found;

				resolver.reset(new tcp::resolver(io_service));
				tcp::resolver::iterator endpoint_iterator = resolver->resolve(query, errorNetwork);

				if (errorNetwork) {
					resolver.reset();
					throw boost::system::system_error(errorNetwork); // No cable, throws here and FD is not closed
				}

				tcp::resolver::iterator end;

				boost::system::error_code error = boost::asio::error::host_not_found;
				while (error && endpoint_iterator != end) {
					socket.reset(new boost::asio::ip::tcp::socket(io_service));
					socket->connect(*endpoint_iterator++, error);
				}

				if (error) {
					throw boost::system::system_error(error); // Valid network throws here and close the FD fine
				}


Do anybody know how can I resolve that?
Could it be an boost issue?!

Thanks a lot.
Topic archived. No new replies allowed.