You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

DuplexPipe.cs 478 B

12345678910111213141516171819
  1. using System.IO.Pipelines;
  2. using System.Threading.Tasks;
  3. namespace Shadowsocks.Protocol
  4. {
  5. class DuplexPipe : IDuplexPipe
  6. {
  7. public PipeReader Input { get; set; }
  8. public PipeWriter Output { get; set; }
  9. public static Task CopyDuplexPipe(IDuplexPipe p1, IDuplexPipe p2)
  10. {
  11. var t1 = p1.Input.CopyToAsync(p2.Output);
  12. var t2 = p2.Input.CopyToAsync(p1.Output);
  13. return Task.WhenAll(t1, t2);
  14. }
  15. }
  16. }