Files
dotnet-systemd-example/Client/Program.cs
T

14 lines
469 B
C#

using System.Net;
using System.Net.Sockets;
using var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
await socket.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 9000));
Console.WriteLine("Type into the console to echo the contents of your message.");
var ns = new NetworkStream(socket);
var readTask = Console.OpenStandardInput().CopyToAsync(ns);
var writeTask = ns.CopyToAsync(Console.OpenStandardOutput());
await Task.WhenAny(readTask, writeTask);