[Boost-users] asio async_write bad address error

1,091 views
Skip to first unread message

Thomas Klein

unread,
Jul 18, 2009, 5:58:24 AM7/18/09
to boost...@lists.boost.org
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 !

Igor R

unread,
Jul 18, 2009, 1:47:17 PM7/18/09
to boost...@lists.boost.org
> 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?
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Thomas Klein

unread,
Jul 18, 2009, 5:50:27 PM7/18/09
to boost...@lists.boost.org

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.

Thomas Klein

unread,
Jul 19, 2009, 4:13:05 AM7/19/09
to boost...@lists.boost.org
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.


Igor R

unread,
Jul 19, 2009, 10:33:06 AM7/19/09
to boost...@lists.boost.org
> 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.

Reply all
Reply to author
Forward
0 new messages