Boost logo

Boost Users :

Subject: [Boost-users] [asio] Grasping the proto-typical socket server
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2013-06-24 17:55:48


Hello,

I've dealt with sockets, and socket servers, in the past, so am
familiar with them. Abstracting out a prototypical server details,
drawing from the plethora of examples, this is what I can determine.

I see three primary abstractions, the server itself, with endpoint
binding, socket connection acceptor, so far so good. Then there's a
connection, which is a sort of io_service to socket adapter. Followed
closely by a session concern, where reads and writes are actually
performed.

Studying the examples, however, it seems to me that by design
io_service wants to be *the* first class citizen that runs, with
asynchronous callbacks being the mode of choice.

How might we go about mixing this code, presumably in the main thread
(?), with any worker service-oriented thread that might be going on.
For instance, I start a thread and wait for it to finish and rejoin
for a main service loop.

Socket connection sessions are secondary to this service behavior
taking place IMO. If a client connects, great, we'll interact with it.
If not, that should be transparent to the application. Possibly
session is a second thread worker with a thread-local-scope
io_service, that we pub/sub messages to the main service loop.

Thoughts on this type of approach?

Much appreciated...

Regards,

Michael


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