本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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);
}