Discussion:
[asio-users] Issues with kqueue on FreeBSD
Mark Studenka
2015-02-18 18:11:37 UTC
Permalink
For some reason boost asio (1_56_0) doesn't seem to want to work for me
out of the box on a FreeBSD 10.0-RELEASE machine. The issue seems to
be a problem with the kqueue implementation somehow.

I've written a small program using boost asio included below that shows the
behavior. I've also written a small program using kqueue calls directly that
works properly (trying to rule out local host configuration issues with using
the kqueue calls themselves.) My boost asio implementation below never
receives the callback after issuing the async_accept() call. If I un-comment
the #define BOOST_ASIO_DISABLE_KQUEUE line everything works properly.

When using the kqueue implementation my telnet session connects to the
process properly but the callback never fires so it seems that the socket is
opened and listening properly.

Any thoughts or ideas would be greatly appreciated.

-mark

#include <stdlib.h>
#include <iostream>

//#define BOOST_ASIO_DISABLE_KQUEUE

#include <boost/asio.hpp>
#include <boost/bind.hpp>

void acceptor(const boost::system::error_code &e)
{
if(!e)
std::cout << "acceptor callback fired" << std::endl;
else
std::cout << "acceptor callback fired (error)" << std::endl;
}

int main(int argc, char **argv)
{
boost::asio::io_service io_service;

boost::asio::ip::tcp::endpoint tcp_endpoint(boost::asio::ip::tcp::v4(), 9999);
boost::asio::ip::tcp::acceptor tcp_acceptor(io_service, tcp_endpoint);

boost::asio::ip::tcp::socket socket(io_service);
tcp_acceptor.async_accept(socket, boost::bind(&acceptor,
boost::asio::placeholders::error));

std::cout << "io_service running.." << std::endl;
io_service.run();
std::cout << "io_service complete" << std::endl;

return(EXIT_SUCCESS);
}



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
asio-users mailing list
asio-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

Loading...