Dart.Snmp Namespace > SnmpBase Class : Send Method |
Public Function Send( _ ByVal message As MessageBase, _ ByVal remoteEP As IPEndPoint _ ) As Integer
Dim instance As SnmpBase Dim message As MessageBase Dim remoteEP As IPEndPoint Dim value As Integer value = instance.Send(message, remoteEP)
public int Send( MessageBase message, IPEndPoint remoteEP )
public: int Send( MessageBase* message, IPEndPoint* remoteEP )
public: int Send( MessageBase^ message, IPEndPoint^ remoteEP )
Exception | Description |
---|---|
System.Net.Sockets.SocketException | A problem occurred using network resources. |
An agent will typically use this method to communicate with SNMP managers. A Trap1Message or Trap2Message can be sent at any time to indicate an alarm. Also used to reply to a RequestMessage. An agent can receive a GetMessage, GetNextMessage, GetBulkMessage or SetMessage request after Agent.Start or Receive is used. CreateResponse is used to create a ResponseMessage that is sent using this method.
A manager can receive an InformMessage after Manager.Start or Receive is used. CreateResponse is used to create a ResponseMessage that is sent using this method.
The AddressFamily of Socket must match the AddressFamily of remoteEP.
If Socket is null, a new Socket is created on IPAddress.Any or IPAddress.IPv6Any as appropriate for remoteEP. Close should be used as warranted.
If Trap1Message.AgentAddress is not set it will be initialized to the address of Socket.
The EncodedMessage property of the message is updated with the encoded message actually sent.
private void TrapSender_Load(object sender, EventArgs e) { //Set sysObjectId to your enterprise number (for Trap1). agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid(), agent1.Mib.CreateVariable(NodeName.sysObjectID, "1.3.6.1.4.1.52222")); } private void buttonSendTrap1_Click(object sender, EventArgs e) { //Send an SNMPv1 Trap agent1.Send(new Dart.Snmp.Trap1.warmStart(agent1.Variables[agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid()].Value.ToString(), agent1.SysUpTime), myManagerAddress); } private void buttonSendTrap2_Click(object sender, EventArgs e) { //Send an SNMPv2 Trap (for SNMPv3, configure warmStart.Security.User) agent1.Send(new Dart.Snmp.Trap2.warmStart(agent1.SysUpTime), myManagerAddress); }
Private Sub TrapSender_Load(ByVal sender As Object, ByVal e As EventArgs) 'Set sysObjectId to your enterprise number (for Trap1). agent1.Variables.Add(agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid(), agent1.Mib.CreateVariable(NodeName.sysObjectID, "1.3.6.1.4.1.52222")) End Sub Private Sub buttonSendTrap1_Click(ByVal sender As Object, ByVal e As EventArgs) 'Send an SNMPv1 Trap agent1.Send(New Dart.Snmp.Trap1.warmStart(agent1.Variables(agent1.Mib.GetByNodeName(NodeName.sysObjectID).GetIid()).Value.ToString(), agent1.SysUpTime), myManagerAddress) End Sub Private Sub buttonSendTrap2_Click(ByVal sender As Object, ByVal e As EventArgs) 'Send an SNMPv2 Trap (for SNMPv3, configure warmStart.Security.User) agent1.Send(New Dart.Snmp.Trap2.warmStart(agent1.SysUpTime), myManagerAddress) End Sub