I try to write simple echo server with .net and linux with code
static async Task soc() {
var listener = new TcpListener(IPAddress.Loopback, 8888);
listener.Start();
for (;;) {
logger.LogInformation("Wait new connetcion");
using(var client = await listener.AcceptTcpClientAsync())
{
logger.LogInformation("Get new connection");
echo(client);
client.Close();
}
}
}
static async void echo(TcpClient client) {
var buf = new byte[512];
using(var stream = client.GetStream())
{
var i = await stream.ReadAsync(buf, 0, 512);
if (i < 1) {
return;
}
await stream.WriteAsync(buf, 0, 512);
}
}
When i use async/await tcp functions like stream.ReadAsync on linux - .net use epoll or plain sockets?
.net core use epoll for async operation on linux, you can see it in runtime sources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With