Agent Object : Start Method |
Visual Basic |
---|
Public Sub Start( _ ByVal localEP As IPEndPoint, _ Optional ByVal freeThreading As Boolean = False, _ Optional ByVal acceptBroadcast As Boolean = True _ ) |
To get a list of possible physical local endpoints to bind to, use IPEndPointList.AddLocalAddresses to populate the IPEndPointList.
This method creates a worker thread that receives SNMP messages sent to the specified local endpoint. An IPv4 socket will only receive packets addressed to IPv4 sockets, just as an IPv6 socket will only receive IPv6 packets. Use multiple Agents to receive packets on multiple sockets.
Error, Log and Request events are raised on the thread Start() was called on. The developer must implement message handling code in the body of the Request event to process SNMP messages, such as in the snippet below.
Close is used to disable communications and release the worker thread used to receive requests on.
Private Sub StartAgent(localAddress As String) 'Populate a variable on the agent Agent1.Variables.Add Agent1.Mib.Nodes("sysDescr").CreateVariable("System Description") 'Establish local binding address Dim localEP As New IPEndPoint localEP.NameOrAddress = localAddress localEP.Port = 161 'Start agent on the specified local binding address Agent1.Start localEP, True End Sub Private Sub Agent1_Request(ByVal requestMessage As DartSnmpCtl.ISnmpMessage) Agent1.SendResponse Agent1.CreateResponse(requestMessage), requestMessage.Origin End Sub