/// <summary> /// Gets the response. /// </summary> /// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param> /// <param name="receiver">The receiver.</param> /// <returns></returns> public ReportMessage GetResponse(int timeout, IPEndPoint receiver) { if (receiver == null) { throw new ArgumentNullException("receiver"); } using (var socket = receiver.GetSocket()) { return((ReportMessage)_discovery.GetResponse(timeout, receiver, Empty, socket)); } }
/// <summary> /// Gets a list of variable binds. /// </summary> /// <param name="version">Protocol version.</param> /// <param name="endpoint">Endpoint.</param> /// <param name="community">Community name.</param> /// <param name="variables">Variable binds.</param> /// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param> /// <returns></returns> public static IList <Variable> Get(VersionCode version, IPEndPoint endpoint, OctetString community, IList <Variable> variables, int timeout) { if (endpoint == null) { throw new ArgumentNullException("endpoint"); } if (community == null) { throw new ArgumentNullException("community"); } if (variables == null) { throw new ArgumentNullException("variables"); } if (version == VersionCode.V3) { throw new NotSupportedException("SNMP v3 is not supported"); } var message = new GetRequestMessage(RequestCounter.NextId, version, community, variables); var response = message.GetResponse(timeout, endpoint); var pdu = response.Pdu(); if (pdu.ErrorStatus.ToInt32() != 0) { throw ErrorException.Create( "error in response", endpoint.Address, response); } return(pdu.Variables); }