Visual Basic (Declaration) | |
---|---|
Public Overloads Function Send( _ ByVal message As MessageBase, _ ByVal hostNameOrAddress As String _ ) As Integer |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As Agent Dim message As MessageBase Dim hostNameOrAddress As String Dim value As Integer value = instance.Send(message, hostNameOrAddress) |
C# | |
---|---|
public int Send( MessageBase message, string hostNameOrAddress ) |
Managed Extensions for C++ | |
---|---|
public: int Send( MessageBase* message, string* hostNameOrAddress ) |
C++/CLI | |
---|---|
public: int Send( MessageBase^ message, String^ hostNameOrAddress ) |
Parameters
- message
- An instance of a ResponseMessage, ReportMessage, TrapMessage or NotificationMessage.
- hostNameOrAddress
- The name or IP address (in dot notation) of the target SNMP manager.
Exception | Description |
---|---|
System.Net.Sockets.SocketException | A problem occurred with network resources. |
System.InvalidOperationException | The provided message parameter is not a ResponseMessage, ReportMessage, TrapMessage or NotificationMessage. |
The following example demonstrates starting a simple agent supporting a MIB variable.
C# | ![]() |
---|---|
private void button1_Click(object sender, EventArgs e) { //Add variable to agent agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace"); agent1.Variables.Values.Add(agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace")); //Start listening for requests agent1.Start(agent1_MessageReceived, null); } private void agent1_MessageReceived(Agent agent, RequestMessage request, object state) { //Create and send a response whenever a request is received agent1.Send(agent1.CreateDefaultResponse(request), request.Origin); } |
Visual Basic | ![]() |
---|---|
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click 'Add variable to agent agent1.Variables.Values.Add(agent1.Mib.CreateVariable(NodeName.sysContact, "Kara Thrace")) 'Start listening for requests agent1.Start(agent1_MessageReceived, Nothing) End Sub Private Sub agent1_MessageReceived(ByVal agent As Agent, ByVal request As RequestMessage, ByVal state As Object) 'Create and send a response whenever a request is received agent1.Send(agent1.CreateDefaultResponse(request), request.Origin) End Sub |
The default trap/notification port of 162 is used.
The EncodedMessage property of the message is updated with the encoded message actually sent.
Target Platforms: Microsoft .NET Framework 2.0