Created
August 30, 2017 15:40
-
-
Save azyobuzin/24c0c3faa681d9556e2adcb164f5df3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private unsafe Task Write(void* ptr, int size) | |
{ | |
var p = (byte*)ptr; | |
var buf = new byte[size]; | |
for (var i = 0; i < buf.Length; i++) | |
buf[i] = p[i]; | |
return this._stream.WriteAsync(buf, 0, size); | |
} | |
private async Task SetupConnection() | |
{ | |
var setupData = new ClientSetupData() | |
{ | |
ByteOrder = BitConverter.IsLittleEndian ? (byte)0x6c : (byte)0x42, | |
ProtocolMajorVersion = 11, | |
ProtocolMinorVersion = 0, | |
LengthOfAuthorizationProtocolName = 0, | |
LengthOfAuthorizationProtocolData = 0, | |
}; | |
Task t; | |
unsafe | |
{ | |
t = this.Write(&setupData, sizeof(ClientSetupData)); | |
} | |
await t.ConfigureAwait(false); | |
throw new NotImplementedException(); | |
} | |
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 12)] | |
private struct ClientSetupData | |
{ | |
[FieldOffset(0)] | |
public byte ByteOrder; | |
[FieldOffset(2)] | |
public ushort ProtocolMajorVersion; | |
[FieldOffset(4)] | |
public ushort ProtocolMinorVersion; | |
[FieldOffset(6)] | |
public ushort LengthOfAuthorizationProtocolName; | |
[FieldOffset(8)] | |
public ushort LengthOfAuthorizationProtocolData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment