-
Notifications
You must be signed in to change notification settings - Fork 3
/
AsyncRequestState.cs
129 lines (127 loc) · 3.28 KB
/
AsyncRequestState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// This file is part of SNMP#NET.
//
// SNMP#NET is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// SNMP#NET is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SNMP#NET. If not, see <http://www.gnu.org/licenses/>.
//
using System.Net;
using System.Threading;
namespace SnmpSharpNet
{
/// <summary>
/// Internal class holding relevant information for async requests.
/// </summary>
internal class AsyncRequestState
{
/// <summary>
/// Peer end point
/// </summary>
protected IPEndPoint _endPoint;
/// <summary>
/// Packet
/// </summary>
protected byte[] _packet;
/// <summary>
/// Packet length
/// </summary>
protected int _packetLength;
/// <summary>
/// Maximum number of retries (0 = single request, no retries)
/// </summary>
protected int _maxRetries;
/// <summary>
/// Request timeout in milliseconds
/// </summary>
protected int _timeout;
/// <summary>
/// Timer class
/// </summary>
protected Timer _timer;
/// <summary>
/// Current retry count. Value represents the number of retries that have been sent
/// excluding the original request.
/// </summary>
protected int _currentRetry;
/// <summary>
/// Get/Set end point
/// </summary>
public System.Net.IPEndPoint EndPoint
{
get { return _endPoint; }
set { _endPoint = value; }
}
/// <summary>
/// Get/Set packet buffer
/// </summary>
public byte[] Packet
{
get { return _packet; }
set { _packet = value; }
}
/// <summary>
/// Get/Set packet length value
/// </summary>
public int PacketLength
{
get { return _packetLength; }
set { _packetLength = value; }
}
/// <summary>
/// Get/Set maximum retry value
/// </summary>
public int MaxRetries
{
get { return _maxRetries; }
set { _maxRetries = value; }
}
/// <summary>
/// Get/Set timeout value
/// </summary>
public int Timeout
{
get { return _timeout; }
set { _timeout = value; }
}
/// <summary>
/// Get/Set timer class
/// </summary>
public System.Threading.Timer Timer
{
get { return _timer; }
set { _timer = value; }
}
/// <summary>
/// Get/Set current retry count
/// </summary>
public int CurrentRetry
{
get { return _currentRetry; }
set { _currentRetry = value; }
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="peerIP">Peer IP address</param>
/// <param name="peerPort">Peer UDP port number</param>
/// <param name="maxretries">Maximum number of retries</param>
/// <param name="timeout">Timeout value in milliseconds</param>
public AsyncRequestState(IPAddress peerIP, int peerPort, int maxretries, int timeout)
{
_endPoint = new IPEndPoint(peerIP, peerPort);
_maxRetries = maxretries;
_timeout = timeout;
// current retry value is set to -1 because we do not count the first request as a retry.
_currentRetry = -1;
_timer = null;
}
}
}