Boost logo

Boost Users :

Subject: Re: [Boost-users] [Asio]What's the behavior of socket.async_write()after socket.close() is called?
From: Peter Foelsche (foelsche_at_[hidden])
Date: 2010-06-06 19:16:20


bad designed api.
close() does not need to be public -- it belongs into the destructor.

>
>
> "?æ½?é£??û" <cometliao_at_[hidden]> wrote in message
> news:AANLkTin6DuWYwIWpf6GAK4TL98drUZ3Q0zsNoomOtfum_at_mail.gmail.com...
> Hi,
> If I call socket.close() but I still have some data in my buffer, can
> I call async_write() later? When I call socket.close(), maybe an
> async_write operation is running, when it's complete I want to send
> data in another buffer(data written while previous async_write() is
> running, before socket.close() was called), but the socket is
> closed.Does it work in this situation?If not, what's the alternative
> way?
> The code looks like this:
>
>
> char front_buffer[kBufferSize];
> char back_buffer[kBufferSize];
>
>
> void HandleWrite(...)
> {
> //socket is closed. Does this work?
> socket.async_write(back_buffer, ...);
> }
>
>
> socket.async_write(front_buffer, HandleWrite);
> // write data to back_buffer
> socket.close();
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net