26 May
2010
26 May
'10
12:51 p.m.
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();