static async Task Main(string[] args) { var messageProtocol = new LengthProtocol(); DoSomethingWithEachClient sa = new DoSomethingWithEachClient(messageProtocol); ReadWriteServer server = new ReadWriteServer(sa); await server.StartAsync(); }
public void Setup() { var options = new PipeOptions(useSynchronizationContext: false); dataPipe = new Pipe(options); _reader = dataPipe.Reader; _writer = dataPipe.Writer; _lengthProtocol = new LengthProtocol(); data = new byte[MessageSize]; data.AsSpan().Fill(1); _message = new Message(data); }
static async Task Main(string[] args) { IMessageProtocol messageProtocol = new LengthProtocol(); Socket socket = new Socket(SocketType.Stream, ProtocolType.Tcp); SocketConnection sc = new SocketConnection(socket); await socket.ConnectAsync(new IPEndPoint(IPAddress.Loopback, 8087)); var connectionTask = sc.StartAsync(); Application app = new Application(sc.ApplicationWriter, sc.ApplicationReader, messageProtocol); var appTask = app.StartAsync(); var readTask = app.StartRecieve(); await Task.WhenAny(connectionTask.AsTask(), appTask, readTask); }