See Also

Agent Class  | Agent Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

localPort
See Also Languages PowerSNMP for .NET

Open(Int32) Method

Dart.PowerSNMP Namespace > Agent Class > Open Method : Open(Int32) Method

Enables the Agent by binding it to a network address. Events will be raised when SNMP packets are received.

[Visual Basic]
Overloads Public Sub Open( _    ByVal localPort As Integer _ )
[C#]
public void Open(    int localPort );
[C++]
public: void Open(    int localPort )
[C++/CLI]
public: void Open(    int localPort )

Parameters

localPort

Exceptions

ExceptionDescription
SocketExceptionA problem was experienced creating a Socket or binding it to the host/port specified.
InvalidOperationExceptionAgent.Socket is already open.

Remarks

The Agent cannot communicate until Open is called. Once called, Agent.Socket returns the Socket in use. Agent.Close should be used to release socket resources.

The SNMP Agent "well-known" port is 161. Managers must be configured to contact this agent on this port if the "well-known" value is not used.

Example

The following example demonstrates opening and closing the Agent component.

[Visual Basic] 


Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
    If (cmdStart.Text = "Start Agent") Then
        'Start the Agent
        Try 'Open port for receiving requests and sending responses
            Agent1.Open()
            cmdStart.Text = "Active"
        Catch ex As Exception
            ShowError(ex.Message)
        End Try
    Else
        'Close Agent
        Agent1.Close()
        cmdStart.Text = "Start Agent"
    End If
End Sub

[C#] 


private void cmdStart_Click(object sender, System.EventArgs e)
{
   
if (cmdStart.Text == "Start Agent")
   {
       
// Start the Agent
       
try // Open port for receiving requests and sending responses
       {
           
agent1.Open();
           cmdStart.Text =
"Active";
       }
       
catch (Exception ex)
       {
           ShowError(ex.Message);
       }
   }
   
else
   {
       
// Close Agent
       
agent1.Close();
       cmdStart.Text =
"Start Agent";
   }
}

                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

Agent Class  | Agent Members  | Overload List


Send comments on this topic.

Documentation version 1.2.0.0.

© 2008 Dart Communications.  All rights reserved.