asio async_write bad address error
Hi there, I'm trying to use boost asio to transfer large objects through a tcp socket. I'm using the Serialization code from the asio documentation as reference. I got a transfer problem and can't find any clue, I'm posting here as a last resort. If someone has a little time to point out my mistakes I'll be really gratefull ! Here is a tgz of a code sample : http://archon.adept.free.fr/asioproblem.tgz In the archive you'll find a server and a client directory. in each directory you'll find a compile.sh file you'll have to adapt to your configuration. In the file asiotestserver/TcpConnection.cpp line 131 you''ll find a comment explaining the transfer problem. Thanks a lot in advance !
Here is a tgz of a code sample : http://archon.adept.free.fr/asioproblem.tgz In the archive you'll find a server and a client directory. in each directory you'll find a compile.sh file you'll have to adapt to your configuration. In the file asiotestserver/TcpConnection.cpp line 131 you''ll find a comment explaining the transfer problem.
At a glance, it seems that in TcpConnection::SendInfo() you try to send *local* buffers asynchronously. Is it really what you're doing, or I'm missing something?
On 18 juil. 09, at 19:47, Igor R wrote:
Here is a tgz of a code sample : http://archon.adept.free.fr/asioproblem.tgz In the archive you'll find a server and a client directory. in each directory you'll find a compile.sh file you'll have to adapt to your configuration. In the file asiotestserver/TcpConnection.cpp line 131 you''ll find a comment explaining the transfer problem.
At a glance, it seems that in TcpConnection::SendInfo() you try to send *local* buffers asynchronously. Is it really what you're doing, or I'm missing something?
Yes, I see, but making buffers a member of TcpConnection class doesn't resolve the problem.
Yes, I see, but making buffers a member of TcpConnection class doesn't resolve the problem.
By saying "buffers" you mean the vector that you pass to async_write()? It's not necessary to make this object the member, as it's passed by value anyway. What I mean is that the *data* you send must outlive the whole async. write process, and your data resides in outboundData & outboundHeader local std::string's. Asio::buffer wrapper is just an adaper, it doesn't copy any underlying data.
On 18 juil. 09, at 19:47, Igor R wrote:
Here is a tgz of a code sample : http://archon.adept.free.fr/asioproblem.tgz In the archive you'll find a server and a client directory. in each directory you'll find a compile.sh file you'll have to adapt to your configuration. In the file asiotestserver/TcpConnection.cpp line 131 you''ll find a comment explaining the transfer problem.
At a glance, it seems that in TcpConnection::SendInfo() you try to send *local* buffers asynchronously. Is it really what you're doing, or I'm missing something?
I got it ! boost::asio::buffer don't make copy of the object "pushed" in it. In this case, a solution is to put outboundHeader and outboundData members of the TcpConnection class. For multiple simultaneous call, I'll manage the data in a singleton. Thanks a lot for the feedback.
participants (2)
-
Igor R
-
Thomas Klein