You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-15 06:40:08 +00:00
## [2.0.22] - 2023-10-03 Integration: - Add support for `XDG_DATA_DIRS` and `.desktop` files on Linux for `VS Code` discovery. - Use compile-time platform-specifics instead of using runtime conditions. Project generation: - Suppress `USG0001` warnings. - Mark referenced assemblies as private (to not copy extra files to output directory when building). - Add Unity capability to SDK-Style projects. - Prevent circular dependency errors with SDK-Style projects.
55 lines
1.3 KiB
C#
55 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 UNITY_EDITOR_WIN
|
|
try
|
|
{
|
|
const int SIO_UDP_CONNRESET = -1744830452;
|
|
|
|
IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, new byte[0]);
|
|
}
|
|
catch
|
|
{
|
|
// fallback
|
|
}
|
|
#endif
|
|
}
|
|
|
|
public static byte[] BufferFor(IAsyncResult result)
|
|
{
|
|
return (byte[])result.AsyncState;
|
|
}
|
|
|
|
public static EndPoint Any()
|
|
{
|
|
return new IPEndPoint(IPAddress.Any, 0);
|
|
}
|
|
}
|
|
}
|