protected override void OnListen() { IPAddress pAddress; string host = this.transportSettings.Host; List <IPAddress> pAddresses = new List <IPAddress>(); if (host.Equals(string.Empty)) { pAddresses.AddRange(Dns.GetHostAddresses(host)); } else if (host.Equals("localhost", StringComparison.OrdinalIgnoreCase) || host.Equals(Environment.MachineName, StringComparison.OrdinalIgnoreCase) || host.Equals(Dns.GetHostEntry(string.Empty).HostName, StringComparison.OrdinalIgnoreCase)) { if (Socket.OSSupportsIPv4) { pAddresses.Add(IPAddress.Any); } if (Socket.OSSupportsIPv6) { pAddresses.Add(IPAddress.IPv6Any); } } else if (!IPAddress.TryParse(host, out pAddress)) { pAddresses.AddRange(Dns.GetHostAddresses(this.transportSettings.Host)); } else { pAddresses.Add(pAddress); } if (pAddresses.Count == 0) { throw new InvalidOperationException(SRAmqp.AmqpNoValidAddressForHost(this.transportSettings.Host)); } this.listenSockets = new Socket[pAddresses.Count]; for (int i = 0; i < pAddresses.Count; i++) { Socket[] socketArray = this.listenSockets; Socket socket = new Socket(pAddresses[i].AddressFamily, SocketType.Stream, ProtocolType.Tcp) { NoDelay = true }; socketArray[i] = socket; this.listenSockets[i].Bind(new IPEndPoint(pAddresses[i], this.transportSettings.Port)); this.listenSockets[i].Listen(this.transportSettings.TcpBacklog); for (int j = 0; j < this.transportSettings.ListenerAcceptorCount; j++) { SocketAsyncEventArgs socketAsyncEventArg = new SocketAsyncEventArgs(); socketAsyncEventArg.Completed += new EventHandler <SocketAsyncEventArgs>(this.OnAcceptComplete); socketAsyncEventArg.UserToken = this.listenSockets[i]; ActionItem.Schedule(this.acceptTransportLoop, socketAsyncEventArg); } } }