//
// SetUnmanagedStructures -
// Fills in Overlapped Structures used in an Async Overlapped Winsock call
// these calls are outside the runtime and are unmanaged code, so we need
// to prepare specific structures and ints that lie in unmanaged memory
// since the Overlapped calls can be Async
//
internal void SetUnmanagedStructures(byte[] buffer, int offset, int size, SocketAddress socketAddress, bool pinSocketAddress)
{
//
// Fill in Buffer Array structure that will be used for our send/recv Buffer
//
m_SocketAddress = socketAddress;
if (pinSocketAddress && m_SocketAddress != null)
{
object[] objectsToPin = null;
objectsToPin = new object[2];
objectsToPin[0] = buffer;
m_SocketAddress.CopyAddressSizeIntoBuffer();
objectsToPin[1] = m_SocketAddress.m_Buffer;
base.SetUnmanagedStructures(objectsToPin);
} else {
base.SetUnmanagedStructures(buffer);
}
m_SingleBuffer.Length = size;
m_SingleBuffer.Pointer = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, offset);
}