createSession static method

Future<Snmp> createSession(
  1. InternetAddress target, {
  2. String community = 'public',
  3. int port = 161,
  4. int trapPort = 162,
  5. int retries = 1,
  6. Duration timeout = const Duration(seconds: 5),
  7. SnmpVersion version = SnmpVersion.v2c,
  8. InternetAddress? sourceAddress,
  9. int? sourcePort,
  10. Level logLevel = logging.Level.INFO,
})

Opens an SNMP v1 or v2c (default) session with target

Implementation

static Future<Snmp> createSession(
  /// The address of the target device we want to communicate with
  InternetAddress target,

  /// The community string to use when communicating via SNMP v1 or v2c
  {
  String community = 'public',

  /// The port which the target device has opened for snmp traffic
  int port = 161,

  /// The local port where we intend to receive snmp trap messages
  int trapPort = 162,

  /// How many times to retry a single snmp request before throwing
  int retries = 1,

  /// How long to wait for a single snmp request to resolve
  Duration timeout = const Duration(seconds: 5),

  /// Which version of snmp to use. (Should be V1 or V2c if using [createSession])
  SnmpVersion version = SnmpVersion.v2c,

  /// The local address to listen for snmp responses on
  InternetAddress? sourceAddress,

  /// The local port to listen for snmp responses on
  int? sourcePort,
  logging.Level logLevel = logging.Level.INFO,
}) async {
  assert(version != SnmpVersion.v3);
  var session = Snmp._(
    target,
    port,
    trapPort,
    retries,
    timeout,
    version,
    community: community,
    logLevel: logLevel,
  );
  await session._bind(address: sourceAddress, port: sourcePort);

  return session;
}