public override IEnumerable <Endpoint> ExpandHost(out Endpoint?publish) { publish = null; // If this endpoint has an empty host (wildcard address), don't expand, just return this endpoint. if (Host.Length == 0) { return(new Endpoint[] { this }); } // If using a fixed port, this endpoint can be used as the published endpoint to access the returned // endpoints. Otherwise, we'll publish each individual expanded endpoint. publish = Port > 0 ? this : null; IEnumerable <IPEndPoint> addresses = Network.GetAddresses(Host, Port, Communicator.IPVersion, EndpointSelectionType.Ordered, Communicator.PreferIPv6); if (addresses.Count() == 1) { return(new Endpoint[] { this }); } else { return(addresses.Select(address => CreateEndpoint(Network.EndpointAddressToString(address), Network.EndpointPort(address), ConnectionId, HasCompressionFlag, Timeout))); } }
public ConnectionInfo GetInfo() { var info = new TCPConnectionInfo(); Socket?fd = _stream.Fd(); if (fd != null) { EndPoint localEndpoint = Network.GetLocalAddress(fd); info.LocalAddress = Network.EndpointAddressToString(localEndpoint); info.LocalPort = Network.EndpointPort(localEndpoint); EndPoint?remoteEndpoint = Network.GetRemoteAddress(fd); info.RemoteAddress = Network.EndpointAddressToString(remoteEndpoint); info.RemotePort = Network.EndpointPort(remoteEndpoint); info.RcvSize = Network.GetRecvBufferSize(fd); info.SndSize = Network.GetSendBufferSize(fd); } return(info); }
public ConnectionInfo GetInfo() { var info = new UDPConnectionInfo(); if (_fd != null) { EndPoint localEndpoint = Network.GetLocalAddress(_fd); info.LocalAddress = Network.EndpointAddressToString(localEndpoint); info.LocalPort = Network.EndpointPort(localEndpoint); if (_state == StateNotConnected) { if (_peerAddr != null) { info.RemoteAddress = Network.EndpointAddressToString(_peerAddr); info.RemotePort = Network.EndpointPort(_peerAddr); } } else { EndPoint?remoteEndpoint = Network.GetRemoteAddress(_fd); if (remoteEndpoint != null) { info.RemoteAddress = Network.EndpointAddressToString(remoteEndpoint); info.RemotePort = Network.EndpointPort(remoteEndpoint); } } info.RcvSize = Network.GetRecvBufferSize(_fd); info.SndSize = Network.GetSendBufferSize(_fd); } if (_mcastAddr != null) { info.McastAddress = Network.EndpointAddressToString(_mcastAddr); info.McastPort = Network.EndpointPort(_mcastAddr); } return(info); }
public string ToDetailedString() { var s = new StringBuilder(ToString()); List <string> intfs; if (_mcastAddr == null) { intfs = Network.GetHostsForEndpointExpand(Network.EndpointAddressToString(_addr), _communicator.IPVersion, true); } else { Debug.Assert(_mcastInterface != null); intfs = Network.GetInterfacesForMulticast(_mcastInterface, Network.GetIPVersion(_mcastAddr.Address)); } if (intfs.Count != 0) { s.Append("\nlocal interfaces = "); s.Append(string.Join(", ", intfs)); } return(s.ToString()); }