Boost logo

Boost :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2007-12-11 09:28:43


   Hi Bert.

> I need to close the connection after sending the last message. At a certain message length the disconnect happens before the message was send completely.
> That's why i thought putting the disconnect via post to the io service will handle this. But this is not the case.
> How can i make a clean disconnect when all outstanding messages were send completely??

   We model our connection's state using a state machine
(boost::statechart rocks :-)) and in this case we would have a state
'sending data' which would simply defer the 'regular disconnect' event
until the next 'sending done' state.

   Second thing that pops to mind is that your large messages may get
fragmented when sending them and you need to send the rest of the
message again after getting notified that the first part got sent.
Then you need to leave the 'sending data' state only after the whole
message gets sent.

   Third thing that pops to mind that you need to be able to handle
'dirty disconnect' events in any state caused by any sort of network
failure. Among other things this requires that the final 'disconnected'
state ignores any further events that might have gotten posted after the
'dirty disconnect' event but before that event got processed.

  And so on, and so on... :-) An endless source of border-conditions to
look out for... :-)))

   Hope this helps...

   Best regards,
     Jurko Gospodnetić


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk