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; }
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."); }
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."); }