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

See Also Languages PowerSNMP for .NET

Open() Method

Dart.PowerSNMP Namespace > Agent Class > Open Method : Open() 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()
[C#]
public void Open();
[C++]
public: void Open();
[C++/CLI]
public: void Open();

Exceptions

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

Remarks

The Agent cannot communicate until Open is called. Once called, Agent.Socket returns the Socket in use. The "well-known" port 161 is used for default operation. Agent.Close should be used to release socket resources.

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.