Exemplo n.º 1
0
 private void CreateNewSocketServer()
 {
     _socket = new UnixDomainSocket();
     _socket.Bind(_path);
     _socket.Listen(_backlog);
     _socket.LingerState.Enabled = false;
 }
Exemplo n.º 2
0
        public override Stream Connect(TimeSpan timeout)
        {
            string address = GetDefaultAddress();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var namedPipe = new NamedPipeClientStream(
                    ".",
                    address,
                    PipeDirection.InOut,
                    PipeOptions.None,
                    TokenImpersonationLevel.Impersonation);
                namedPipe.Connect((int)timeout.TotalMilliseconds);
                return(namedPipe);
            }
            else
            {
                var socket = new UnixDomainSocket();
                socket.Connect(Path.Combine(IpcRootPath, address), timeout);
                return(new ExposedSocketNetworkStream(socket, ownsSocket: true));
            }
        }
Exemplo n.º 3
0
        public override async Task <Stream> ConnectAsync(CancellationToken token)
        {
            string address = GetDefaultAddress();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var namedPipe = new NamedPipeClientStream(
                    ".",
                    address,
                    PipeDirection.InOut,
                    PipeOptions.None,
                    TokenImpersonationLevel.Impersonation);
                await namedPipe.ConnectAsync(token).ConfigureAwait(false);

                return(namedPipe);
            }
            else
            {
                var socket = new UnixDomainSocket();
                await socket.ConnectAsync(Path.Combine(IpcRootPath, address), token).ConfigureAwait(false);

                return(new ExposedSocketNetworkStream(socket, ownsSocket: true));
            }
        }