当前位置: 首页>>代码示例>>C#>>正文


C# IPEndPoint.GetSocket方法代码示例

本文整理汇总了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;
        }
开发者ID:Sangman,项目名称:NETManager,代码行数:27,代码来源:SNMP.cs

示例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);
            }
        }
开发者ID:nickolaykon,项目名称:sharpsnmplib,代码行数:30,代码来源:SnmpMessageExtension.cs

示例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);
            }
        }
开发者ID:stubarr,项目名称:sharpsnmplib-1,代码行数:18,代码来源:Discovery.cs


注:本文中的System.Net.IPEndPoint.GetSocket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。