/// <summary> /// Find the list of currently bound local sockets. /// </summary> /// <param name="countersReader"> for the connected driver. </param> /// <param name="channelStatus"> value for the channel which aggregates the transports. </param> /// <param name="channelStatusId"> identity of the counter for the channel which aggregates the transports. </param> /// <returns> the list of active bound local socket addresses. </returns> public static List <string> FindAddresses(CountersReader countersReader, long channelStatus, int channelStatusId) { if (channelStatus != ChannelEndpointStatus.ACTIVE) { return(new List <string>()); } List <string> bindings = new List <string>(2); IDirectBuffer buffer = countersReader.MetaDataBuffer; for (int i = 0, size = countersReader.MaxCounterId; i < size; i++) { if (countersReader.GetCounterState(i) == CountersReader.RECORD_ALLOCATED && countersReader.GetCounterTypeId(i) == LOCAL_SOCKET_ADDRESS_STATUS_TYPE_ID) { int recordOffset = CountersReader.MetaDataOffset(i); int keyIndex = recordOffset + CountersReader.KEY_OFFSET; if (channelStatusId == buffer.GetInt(keyIndex + CHANNEL_STATUS_ID_OFFSET) && ChannelEndpointStatus.ACTIVE == countersReader.GetCounterValue(i)) { int length = buffer.GetInt(keyIndex + LOCAL_SOCKET_ADDRESS_LENGTH_OFFSET); if (length > 0) { bindings.Add(buffer.GetStringWithoutLengthAscii( keyIndex + LOCAL_SOCKET_ADDRESS_STRING_OFFSET, length)); } } } } return(bindings); }