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


C# Socket.SetIPProtectionLevel方法代码示例

本文整理汇总了C#中System.Net.Sockets.Socket.SetIPProtectionLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.SetIPProtectionLevel方法的具体用法?C# Socket.SetIPProtectionLevel怎么用?C# Socket.SetIPProtectionLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Sockets.Socket的用法示例。


在下文中一共展示了Socket.SetIPProtectionLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UdpConnection

        /// <summary>
        /// Initializes a new instance of the <see cref="UdpConnection"/> class.
        /// </summary>
        /// <param name="udpClient">The UDP client.</param>
        /// <param name="endPoint">The endPoint where we want to receive the data.</param>
        internal UdpConnection(UdpClient udpClient, IPEndPoint remoteEndPoint, bool writeLock = false)
            : base()
        {
            client = udpClient;
            WriteLock = writeLock;
            socket = client.Client;
            ipEndPoint = remoteEndPoint;
            client.Connect(remoteEndPoint);

            KeepAlive = false;
            socket.SendTimeout = 0;
            socket.ReceiveTimeout = 0;
            socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);

            Init();
        }
开发者ID:wouldntsavezion,项目名称:KappaGame,代码行数:21,代码来源:UdpConnection.cs

示例2: Main

        public static void Main(string[] args)
        {
            Test().Wait();

            Console.WriteLine("");
            Console.WriteLine("Socket listening on port 1602. Remember, it is mapped to external port 1702!!!");
            Console.WriteLine("Test it with http://www.canyouseeme.org/ online tool");

            var endPoint = new IPEndPoint(IPAddress.Any, 1602);
            var socket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
            socket.Bind(endPoint);
            socket.Listen(4);

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
            socket.Close();
        }
开发者ID:theTwist84,项目名称:Open.NAT,代码行数:18,代码来源:Main.cs

示例3: CreateSocket

 protected override Socket CreateSocket()
 {
     var socket = new Socket(EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
         socket.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
         socket.Bind(EndPoint);
         socket.Listen(4);
         return socket;
 }
开发者ID:jpalmero9,项目名称:peer2net,代码行数:8,代码来源:Listener.cs

示例4: SendRaw

 /// <summary>
 /// Send raw packet containing 'text' to the wifilink
 /// </summary>
 /// <param name="text">contents of packet.</param>
 public void SendRaw(string text)
 {
     Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
     sock.SetIPProtectionLevel(IPProtectionLevel.Unrestricted);
     sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
     IPAddress serverAddr = IPAddress.Parse("192.168.1.8");
     IPEndPoint endPoint = new IPEndPoint(serverAddr, 9760);
     byte[] send_buffer = Encoding.ASCII.GetBytes(text);
     sock.SendTo(send_buffer, endPoint);
 }
开发者ID:kingtut666,项目名称:holly,代码行数:14,代码来源:LWRF.cs


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