Hello I am currently tring to realize a server program with Boost.Asio.
Since I am rather unexperienced on that topic I simply took the example code as a basis to test if I can make it work (the SSL example code to be precise (since I am using SSL) ->
http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/example/ssl/server.cpp )
I only slightly modified the code so everything is pretty much the same as in the example of the link (excpet that I modified context_ a little).
So first of all it would be nice if someone could explain to me what happens when a client connects :D
I mean I know that the incoming connection first gets accepted with
start_accept()
and a new object of
session
is created where the packets are recieved and sent back but how exactly does the "handler" stuff work?
For example, what are the functions
handle_handshake(...)
,
handle_read(...)
and
handle_write(...)
doing and where are they called? What confuses me most is that in
handle_read(...)
,
async_write(..)
is called and in
handle_write(...)
,
socket_.async_read_some(..)
which seems kind of contradictory to me.
I already managed to get the code working and a packet is successfully recieved from the client but for some reason I get the data somewhere between handle_handshake and handle_read (and not after read or after handle_handshake what I would think), is that correct so?
If yes, then what's the purpose of handle_read/handle_handshake?
Its hard for me to fully understand the example code when there are no comments whatsoever in it.
Also I would like to know if it is possible to send two (or more) consecutive tcp packets back to the client, is this possible (with the ssl example)? If yes please give me an example what it would look like, thanks in advance.