Manager Object : GetResponse Method |
Visual Basic |
---|
Public Function GetResponse( _ ByVal requestMessage As SnmpMessage, _ ByVal targetEP As IPEndPoint, _ ByVal localEP As IPEndPoint, _ Optional ByVal timeout As Integer = 1000, _ Optional ByVal retries As Integer = 2, _ Optional ByVal threading As ThreadingConstants = threadingBlock, _ Optional ByVal userState As Variant _ ) As SnmpMessage |
Value | Description |
---|---|
threadingAsync | Implements Apartment Model threading without method blocking. |
threadingBlock | Implements Apartment Model threading with method blocking (UI messages are processed). |
threadingFree | Implements Free Model threading with method blocking (UI messages are not processed). |
A new socket is created and used each time this method executes.
If localEP is specified, the socket is bound to the specified address family, address and port for the operation. If NULL/Nothing, a socket is created that uses a compatible 'Any' local interface and an ephemeral port.
When used asynchronously (threading is threadingAsync), the Response event will be raised providing access to the response after it has been received, and the Error event will be raised if any error occurs.
Private Function GetSysDescr(agentEP As IPEndPoint, version As Integer, snmpUser As User) As String Dim msg As New SnmpMessage msg.community = "public" msg.Variables.Add Manager1.Mib.Nodes.Item("sysDescr").CreateVariable() If version = 1 Then msg.Type = PduConstants.pduGet1 ElseIf version = 2 Then msg.Type = PduConstants.pduGet2 Else msg.Type = PduConstants.pduGet3 msg.Security.User = snmpUser End If Dim response As SnmpMessage Set response = Manager1.GetResponse(msg, agentEP, Nothing) GetSysDescr = response.Variables(0).ValueAsString End Function