TransportListener(IPEndPoint endPoint)
        {
            if (TD.TcpTransportListenerListeningStartIsEnabled())
            {
                TD.TcpTransportListenerListeningStart(this.EventTraceActivity, GetRemoteEndpointAddressPort(endPoint));
            }

            transportType = TransportType.Tcp;
            SocketSettings socketSettings = new SocketSettings();
            IConnectionListener connectionListener = null;
            if (endPoint.Address.Equals(IPAddress.Broadcast))
            {
                if (Socket.OSSupportsIPv4)
                {
                    connectionListener = new SocketConnectionListener(new IPEndPoint(IPAddress.Any, endPoint.Port), socketSettings, true);
                    demuxer = Go(connectionListener);
                }

                if (Socket.OSSupportsIPv6)
                {
                    connectionListener = new SocketConnectionListener(new IPEndPoint(IPAddress.IPv6Any, endPoint.Port), socketSettings, true);
                    demuxerV6 = Go(connectionListener);
                }
            }
            else
            {
                connectionListener = new SocketConnectionListener(endPoint, socketSettings, true);
                demuxer = Go(connectionListener);
            }

            if (TD.TcpTransportListenerListeningStopIsEnabled())
            {
                TD.TcpTransportListenerListeningStop(this.EventTraceActivity);
            }
        }
        TransportListener(BaseUriWithWildcard pipeUri)
        {
            if (TD.PipeTransportListenerListeningStartIsEnabled())
            {
                TD.PipeTransportListenerListeningStart(this.EventTraceActivity, (pipeUri.BaseAddress != null) ? pipeUri.BaseAddress.ToString() : string.Empty);
            }

            transportType = TransportType.NamedPipe;
            IConnectionListener connectionListener = new PipeConnectionListener(pipeUri.BaseAddress, pipeUri.HostNameComparisonMode,
                ListenerConstants.SharedConnectionBufferSize, null, false, int.MaxValue);
            demuxer = Go(connectionListener);

            if (TD.PipeTransportListenerListeningStopIsEnabled())
            {
                TD.PipeTransportListenerListeningStop(this.EventTraceActivity);
            }
        }
示例#3
0
        internal ListenerConnectionDemuxer Go(IConnectionListener connectionListener)
        {
            if (DiagnosticUtility.ShouldTraceInformation)
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListenRequest, SR.GetString(SR.TraceCodeTransportListenerListenRequest), this);
            }

            ConnectionHandleDuplicated onDupHandle       = new ConnectionHandleDuplicated(OnDupHandle);
            ListenerConnectionDemuxer  connectionDemuxer = null;

            if (transportType == TransportType.Tcp)
            {
                connectionDemuxer = new ListenerConnectionDemuxer(connectionListener,
                                                                  transportType,
                                                                  ListenerConfig.NetTcp.MaxPendingAccepts,
                                                                  ListenerConfig.NetTcp.MaxPendingConnections,
                                                                  ListenerConfig.NetTcp.ReceiveTimeout,
                                                                  onDupHandle);
            }
            else if (transportType == TransportType.NamedPipe)
            {
                connectionDemuxer = new ListenerConnectionDemuxer(connectionListener,
                                                                  transportType,
                                                                  ListenerConfig.NetPipe.MaxPendingAccepts,
                                                                  ListenerConfig.NetPipe.MaxPendingConnections,
                                                                  ListenerConfig.NetPipe.ReceiveTimeout,
                                                                  onDupHandle);
            }

            if (ExecutionContext.IsFlowSuppressed())
            {
                if (SecurityContext.IsFlowSuppressed())
                {
                    connectionDemuxer.StartDemuxing();
                }
                else
                {
                    using (SecurityContext.SuppressFlow())
                    {
                        connectionDemuxer.StartDemuxing();
                    }
                }
            }
            else
            {
                using (ExecutionContext.SuppressFlow())
                {
                    if (SecurityContext.IsFlowSuppressed())
                    {
                        connectionDemuxer.StartDemuxing();
                    }
                    else
                    {
                        using (SecurityContext.SuppressFlow())
                        {
                            connectionDemuxer.StartDemuxing();
                        }
                    }
                }
            }

            if (DiagnosticUtility.ShouldTraceInformation)
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListening, SR.GetString(SR.TraceCodeTransportListenerListening), this);
            }

            return(connectionDemuxer);
        }
        internal ListenerConnectionDemuxer Go(IConnectionListener connectionListener)
        {
            if (DiagnosticUtility.ShouldTraceInformation)
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListenRequest, SR.GetString(SR.TraceCodeTransportListenerListenRequest), this);
            }

            ConnectionHandleDuplicated onDupHandle = new ConnectionHandleDuplicated(OnDupHandle);
            ListenerConnectionDemuxer connectionDemuxer = null;

            if (transportType == TransportType.Tcp)
            {
                connectionDemuxer = new ListenerConnectionDemuxer(connectionListener,
                    transportType,
                    ListenerConfig.NetTcp.MaxPendingAccepts,
                    ListenerConfig.NetTcp.MaxPendingConnections,
                    ListenerConfig.NetTcp.ReceiveTimeout,
                    onDupHandle);
            }
            else if (transportType == TransportType.NamedPipe)
            {
                connectionDemuxer = new ListenerConnectionDemuxer(connectionListener,
                    transportType,
                    ListenerConfig.NetPipe.MaxPendingAccepts,
                    ListenerConfig.NetPipe.MaxPendingConnections,
                    ListenerConfig.NetPipe.ReceiveTimeout,
                    onDupHandle);
            }

            if (ExecutionContext.IsFlowSuppressed())
            {
                if (SecurityContext.IsFlowSuppressed())
                {
                    connectionDemuxer.StartDemuxing();
                }
                else
                {
                    using (SecurityContext.SuppressFlow())
                    {
                        connectionDemuxer.StartDemuxing();
                    }
                }
            }
            else
            {
                using (ExecutionContext.SuppressFlow())
                {
                    if (SecurityContext.IsFlowSuppressed())
                    {
                        connectionDemuxer.StartDemuxing();
                    }
                    else
                    {
                        using (SecurityContext.SuppressFlow())
                        {
                            connectionDemuxer.StartDemuxing();
                        }
                    }
                }
            }

            if (DiagnosticUtility.ShouldTraceInformation)
            {
                ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.TransportListenerListening, SR.GetString(SR.TraceCodeTransportListenerListening), this);
            }

            return connectionDemuxer;
        }