Пример #1
0
 public NamedPipesServer(string address, RequestHandler requestHandler, Action<string> log = null)
     : base(address, requestHandler, HostUtils.DefaultLog("NamedPipesServer: ", log))
 {
     if (!address.StartsWith("namedpipe"))
     {
         throw new InvalidOperationException("Only named pipe transport is supported.");
     }
     _address = address;
 }
Пример #2
0
 public NamedPipesClientConnection(string address, Action <string> log = null)
 {
     _address = address.Replace(@"namedpipes://\\.\pipe\", "");
     _log     = HostUtils.DefaultLog("Host: ", log);
     _log($"Connecting to named pipe {_address}...");
     _clientStream = new NamedPipeClientStream(_address);
     _clientStream.Connect();
     _streamReader = new StreamReader(_clientStream);
     _streamWriter = new StreamWriter(_clientStream)
     {
         AutoFlush = true
     };
     _log("Connected.");
 }
Пример #3
0
        public TcpClientConnection(string address, Action <string> log = null)
        {
            address = address.Replace("//:", "//127.0.0.1:");
            var url = new Uri(address);

            log = HostUtils.DefaultLog("TcpClient: ", log);

            log($"Connecting to {url} over TCP...");

            _client = new TcpClient(url.Host, url.Port);

            var stream = _client.GetStream();

            _streamReader = new StreamReader(stream);
            _streamWriter = new StreamWriter(stream)
            {
                AutoFlush = true
            };
            log("Connected.");
        }