Boost logo

Boost Users :

Subject: [Boost-users] ASIO - Using IO service from main program in a .so loaded with dlopen, dlsym, etc.
From: J.W.F. Thirion (derik_at_[hidden])
Date: 2009-08-29 02:08:33


Dear Community,

I've got an application that loads a .so using dlopen, dlsym, etc. It
also starts up an IO service pool and manages them. The application
implements a socket server, that starts a thread for each incoming
connection. Inside each of the threads started, a .so function is called
based on information received on the socket.

Inside the function of the .so, I want to connect to a remote server
using the IO service in the main program (that called the dlopen, etc.).
It seems, however, that if I use an IO service not created inside
the .so, the handle_connect never gets called by ASIO.

Is anyone aware of this problem. I suppose I'm just doing something
stupid w.r.t. shared object usage (maybe permissions, etc.). Or is the
ASIO library not initialised inside the DLL? When I create an IO service
pool inside the .so, everything works, but obviously this is not ideal
as the pool starts threads that execute the run() method on the io
service.

Interesting thing is that I can actually pass a session object (from the
socket server accept operation) from my main program to the .so function
and have messages read and written on the socket. But when I try and
create a new connection using the session's IO service (e.g. from a
sock.get_io_service() call), then I never get the handle_connect.

I've even tried:
#pragma GCC visibility push(default)
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#pragma GCC visibility pop

around the boost includes, but no luck.

Any help on this would be greatly appreciated.

Kind regards,
Derik Thirion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net