Skip to content

Commit ad864b2

Browse files
committed
fix(async): improve TCP write and accept handling
1 parent 5408794 commit ad864b2

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/net/asio_tcp.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ namespace vix::async::net
140140
ct,
141141
[&](auto done)
142142
{
143-
asio::async_write(
144-
sock_,
143+
sock_.async_write_some(
145144
asio::buffer(buf.data(), buf.size()),
146145
[done = std::move(done)](
147146
std::error_code ec,
@@ -255,8 +254,14 @@ namespace vix::async::net
255254
{
256255
acc->async_accept(
257256
client_ptr->native(),
258-
[acc, done = std::move(done)](std::error_code ec) mutable
257+
[acc, client_ptr, done = std::move(done)](std::error_code ec) mutable
259258
{
259+
if (!ec)
260+
{
261+
std::error_code ignored;
262+
client_ptr->native().set_option(tcp::no_delay(true), ignored);
263+
}
264+
260265
done(ec);
261266
});
262267
});

0 commit comments

Comments
 (0)