Files
RobustToolbox/Lidgren.Network/Platform/NativeSocket.Structs.cs
Tyler Young faff0797bf Make Lidgren Use Spans & Shared Pool (#1140)
* make lidgren use spans everywhere where it can

convert custom pooling to shared array pool impl

add unit tests for read/write

add native socket extensions to socket so we can legit pass spans for SendTo/ReceiveFrom

bump version in lidgren csproj

replace some random "% 8" w/ "& 7"

more minor nullability hacks to fix static analysis complaints

made receiving packets use span

minor native sockets refactor to use pinvoke

add read/write constrained/prealloc'd bit stream impl to lidgren and update usages

fixed missing stream cleanup

remove outstanding stream cleanup since it refs buffer thru the class, can't read some other buf

apply suggestions from code review

remove unsafe cruft

* add tests to gh actions

* make stats use interpolation in tostring and remove m_bytesAllocated since it's all in the shared pool now

* this pr still open so fuck it

stats, human readability, faster BitsToHold methods

* add api compatible version of ReadBytes

* rename ReadOnlyStreamWrapper -> ReadOnlyWrapperStream

rename WriteOnlyStreamWrapper -> WriteOnlyWrapperStream

add AppendViaStream, AppenderStream impl

add and update documentation on read/write bytes methods

also fix some goofs
2020-06-24 04:09:20 +02:00

52 lines
978 B
C#

using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
#pragma warning disable 649
namespace Lidgren.Network {
public static partial class NativeSockets {
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
[StructLayout(LayoutKind.Sequential, Size = SockAddrStorageSize)]
private struct SockAddr {
public ushort SocketAddressFamily;
}
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
private struct SockAddrIn {
public ushort SocketAddressFamily;
public ushort Port;
public uint InAddr;
public ulong Zero;
}
[StructLayout(LayoutKind.Sequential, Size = 16)]
private struct InAddr6 {
}
[SuppressMessage("ReSharper", "NotAccessedField.Local")]
private struct SockAddrIn6 {
public ushort SocketAddressFamily;
public ushort Port;
public uint FlowInfo;
public InAddr6 InAddr;
public uint InScopeId;
}
}
}