本文整理汇总了C#中System.Net.IPEndPoint.GetSocket方法的典型用法代码示例。如果您正苦于以下问题:C# IPEndPoint.GetSocket方法的具体用法?C# IPEndPoint.GetSocket怎么用?C# IPEndPoint.GetSocket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.IPEndPoint
的用法示例。
在下文中一共展示了IPEndPoint.GetSocket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMIB
/// <summary>
/// Get the Management Information Base of one SNMP agent.
/// </summary>
/// <param name="agentEP">IPEndPoint of the device with the agent.</param>
/// <returns>MIB as a Dictionary</returns>
internal static Dictionary<String, String> GetMIB(IPEndPoint agentEP)
{
Dictionary<String, String> mib = new Dictionary<String, String>();
// start
String id = ".0.0";
do {
GetNextRequestMessage message = new GetNextRequestMessage(0,
VersionCode.V1,
new OctetString("public"), // returns messageexception if false community string
new List<Variable> { new Variable(new ObjectIdentifier(id)) });
ResponseMessage response = (ResponseMessage)message.GetResponse(100, agentEP, new UserRegistry(), agentEP.GetSocket());
// get id
id = response.Scope.Pdu.Variables[0].Id.ToString();
if (mib.ContainsKey(id)) break;
mib.Add(id, response.Scope.Pdu.Variables[0].Data.ToString());
} while (true);
return mib;
}
示例2: GetResponse
/// <summary>
/// Sends this <see cref="ISnmpMessage"/> and handles the response from agent.
/// </summary>
/// <param name="request">The <see cref="ISnmpMessage"/>.</param>
/// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param>
/// <param name="receiver">Port number.</param>
/// <returns></returns>
public static ISnmpMessage GetResponse(this ISnmpMessage request, int timeout, IPEndPoint receiver)
{
if (request == null)
{
throw new ArgumentNullException("request");
}
if (receiver == null)
{
throw new ArgumentNullException("receiver");
}
var code = request.TypeCode();
if (code == SnmpType.TrapV1Pdu || code == SnmpType.TrapV2Pdu || code == SnmpType.ReportPdu)
{
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "not a request message: {0}", code));
}
using (var socket = receiver.GetSocket())
{
return request.GetResponse(timeout, receiver, socket);
}
}
示例3: GetResponse
/// <summary>
/// Gets the response.
/// </summary>
/// <param name="timeout">The time-out value, in milliseconds. The default value is 0, which indicates an infinite time-out period. Specifying -1 also indicates an infinite time-out period.</param>
/// <param name="receiver">The receiver.</param>
/// <returns></returns>
public ReportMessage GetResponse(int timeout, IPEndPoint receiver)
{
if (receiver == null)
{
throw new ArgumentNullException("receiver");
}
using (var socket = receiver.GetSocket())
{
return (ReportMessage)_discovery.GetResponse(timeout, receiver, Empty, socket);
}
}