You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-15 14:50:08 +00:00
## [2.0.7] - 2021-02-02 Integration: Remove com.unity.nuget.newtonsoft-json dependency in favor of the built-in JsonUtility for the VS Test Runner. ## [2.0.6] - 2021-01-20 Project generation: - Improved language version detection. Integration: - Added support for the VS Test Runner. - Added initial support for displaying asset usage. - Fixed remaining issues with special characters in file/path.
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
using System;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace Microsoft.Unity.VisualStudio.Editor.Messaging
|
|
{
|
|
internal class UdpSocket : Socket
|
|
{
|
|
// Maximum UDP payload is 65507 bytes.
|
|
// TCP mode will be used when the payload is bigger than this BufferSize
|
|
public const int BufferSize = 1024 * 8;
|
|
|
|
internal UdpSocket()
|
|
: base(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
|
|
{
|
|
SetIOControl();
|
|
}
|
|
|
|
public void Bind(IPAddress address, int port = 0)
|
|
{
|
|
Bind(new IPEndPoint(address ?? IPAddress.Any, port));
|
|
}
|
|
|
|
private void SetIOControl()
|
|
{
|
|
if (!VisualStudioEditor.IsWindows)
|
|
return;
|
|
|
|
try
|
|
{
|
|
const int SIO_UDP_CONNRESET = -1744830452;
|
|
|
|
IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, new byte[0]);
|
|
}
|
|
catch
|
|
{
|
|
// fallback
|
|
}
|
|
}
|
|
|
|
public static byte[] BufferFor(IAsyncResult result)
|
|
{
|
|
return (byte[])result.AsyncState;
|
|
}
|
|
|
|
public static EndPoint Any()
|
|
{
|
|
return new IPEndPoint(IPAddress.Any, 0);
|
|
}
|
|
}
|
|
}
|