C# Class SnmpSharpNet.UdpTransport

IP/UDP transport class.
Inheritance: IDisposable
显示文件 Open project: griffina/SnmpSharpNet

Protected Properties

Property Type Description
_isIPv6 bool
_noSourceCheck bool
_socket Socket

Public Methods

Method Description
Close ( ) : void

Close network socket

Dispose ( ) : void

Dispose of the class.

Request ( IPAddress peer, int port, byte buffer, int bufferLength, int timeout, int retries ) : byte[]

Make sync request using IP/UDP with request timeouts and retries.

UdpTransport ( bool useV6 ) : System

Constructor. Initializes and binds the Socket class

Protected Methods

Method Description
initSocket ( bool useV6 ) : void

Initialize class socket

Private Methods

Method Description
AsyncRequestTimerCallback ( object stateInfo ) : void

Internal timer callback. Called by _asyncTimer when SNMP request timeout has expired

ReceiveBegin ( ) : void

Begin async version of ReceiveFrom member of the socket class.

ReceiveFromCallback ( IAsyncResult ar ) : void

Internal callback called as part of Socket.BeginReceiveFrom. Process incoming packets and notify caller of results.

RequestAsync ( IPAddress peer, int port, byte buffer, int bufferLength, int timeout, int retries, SnmpAsyncCallback asyncCallback ) : bool

Begin an async SNMP request

RetryAsyncRequest ( ) : void

Internal retry function. Checks if request has reached maximum number of retries and either resends the request if not reached, or sends request timed-out notification to the caller if maximum retry count has been reached and request has failed.

SendToBegin ( ) : void

Calls async version of the SendTo socket function.

SendToCallback ( IAsyncResult ar ) : void

Callback member called on completion of BeginSendTo send data operation.

Method Details

Close() public method

Close network socket
public Close ( ) : void
return void

Dispose() public method

Dispose of the class.
public Dispose ( ) : void
return void

Request() public method

Make sync request using IP/UDP with request timeouts and retries.
Thrown on request timed out. SnmpException.ErrorCode is set to /// SnmpException.RequestTimedOut constant. Thrown when IPv4 address is passed to the v6 socket or vice versa
public Request ( IPAddress peer, int port, byte buffer, int bufferLength, int timeout, int retries ) : byte[]
peer System.Net.IPAddress SNMP agent IP address
port int SNMP agent port number
buffer byte Data to send to the agent
bufferLength int Data length in the buffer
timeout int Timeout in milliseconds
retries int Maximum number of retries. 0 = make a single request with no retry attempts
return byte[]

UdpTransport() public method

Constructor. Initializes and binds the Socket class
public UdpTransport ( bool useV6 ) : System
useV6 bool Set to true if you wish to initialize the transport for IPv6
return System

initSocket() protected method

Initialize class socket
protected initSocket ( bool useV6 ) : void
useV6 bool Should socket be initialized for IPv6 (true) of IPv4 (false)
return void

Property Details

_isIPv6 protected_oe property

Flag showing if class is using IPv6 or IPv4
protected bool _isIPv6
return bool

_noSourceCheck protected_oe property

Internal variable used to disable host IP address/port number check on received SNMP reply packets. If this option is disabled (default) only replies from the IP address/port number combination to which the request was sent will be accepted as valid packets. This value is set in the AgentParameters class and is only valid for SNMP v1 and v2c requests.
protected bool _noSourceCheck
return bool

_socket protected_oe property

Socket
protected Socket _socket
return Socket