How to flush the socket using boost -


I am implementing a server that sends XML to promote the client. The problem I am facing is that the buffer is not sent immediately and deposits at one point sends the whole thing, it creates a problem on my client side, when it parses the XML, in it Can be an incomplete XML tag (incomplete message). Whenever there is a need to send a message, is there any way to take out the socket? Below is the server's writing code.

  void ClientConnection :: handle_write (const boost :: system :: error_code & error) {if (! Error) {m_push_message_queue.pop_front (); If (! M_push_message_queue.empty () & amp; amp;! M_Disynticated) {boost :: asio :: async_write (m_socket, boost :: asio :: buffer (m_push_message_queue.front () .data (), m_push_message_queue.front () Length ()), Promotion :: Bind (& amp; Client Connection :: handle_write, this, boost :: asio :: placeholders :: error)); }} And {std :: err & lt; & Lt; "Error in exiting message ... \ n"; M_disconnected = true; M_server-> DisconnectedClient (this); Typically when TCP creates an application using the byte stream, the sender sends a fixed length header. Therefore the receiver knows how many bytes are expected. Then the receiver reads that several bytes and the resulting buffer parses in the XML object. 


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -