Hello
How can i use the Interface IElementConnection to get the IP of polling for elements? it for process an inventory.
Thanks
Juan
Hi Juan,
I believe this is what you meant, but I'm not completely sure. First, you'll need to determine the type of connection. If it's an HTTP connection, you can retrieve the IP address like this (connection is of type IElementConnection):
foreach (var connection in connections)
{
IHttpConnection httpConnection = connection as IHttpConnection;
if (httpConnection != null)
{
var remoteHost = httpConnection.TcpConfiguration.RemoteHost;
// Use remoteHost as needed
}
}

Glad it helped! I actually pulled that from the DataMiner docs, there's a good example on how to create an element with connections:
https://docs.dataminer.services/develop/devguide/ClassLibrary/ClassLibraryElementCreation.html#creating-an-element-with-connections
I just used some basic C# casting to check if the connection was HTTP and then grabbed the IP from TcpConfiguration.RemoteHost.
Thanks this is what i need, i used with snmp version
var connections = element.Connections;
foreach(var connection in connections)
{
ISnmpConnection snmpConnection = connection as ISnmpConnection;
if (snmpConnection != null)
{
ip = snmpConnection.UdpConfiguration.RemoteHost;
}
}