feat: finish normal binding socket example
This commit is contained in:
+13
-2
@@ -1,2 +1,13 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
Console.WriteLine("Hello, World!");
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user