PowerSNMP for .NET CF
Send Method
See Also  Example Send comments on this topic.
Dart.Snmp Namespace > SnmpBase Class : Send Method




message
An instance of a ResponseMessage, ReportMessage, TrapMessage or NotificationMessage.
remoteEndPoint
An IPEndPoint that specifies the network address of an SNMP manager. Usually used when replying to a RequestMessage received from a manager.
Send a message to the SNMP manager specified.

Syntax

Visual Basic (Declaration) 
Public Function Send( _
   ByVal message As MessageBase, _
   ByVal remoteEndPoint As IPEndPoint _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As SnmpBase
Dim message As MessageBase
Dim remoteEndPoint As IPEndPoint
Dim value As Integer
 
value = instance.Send(message, remoteEndPoint)
C# 
public int Send( 
   MessageBase message,
   IPEndPoint remoteEndPoint
)
Managed Extensions for C++ 
public: int Send( 
   MessageBase* message,
   IPEndPoint* remoteEndPoint
) 
C++/CLI 
public:
int Send( 
   MessageBase^ message,
   IPEndPoint^ remoteEndPoint
) 

Parameters

message
An instance of a ResponseMessage, ReportMessage, TrapMessage or NotificationMessage.
remoteEndPoint
An IPEndPoint that specifies the network address of an SNMP manager. Usually used when replying to a RequestMessage received from a manager.

Exceptions

ExceptionDescription
System.Net.Sockets.SocketExceptionA problem occurred with network resources.
System.InvalidOperationExceptionThe provided message parameter is not a ResponseMessage, ReportMessage, TrapMessage or NotificationMessage.

Example

The following example demonstrates starting a simple agent supporting a MIB variable.
C#Copy Code
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 BasicCopy Code
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

Remarks

The EncodedMessage property of the message is updated with the encoded message actually sent.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.2
© 2010 Dart Communications. All Rights Reserved.