MSDN documentation, số MSDN column của Keith Brown và pinvoke.net giúp tôi hầu hết mọi cách. Nhưng nhận được PSOCKADDR trong chính xác HTTP_SERVICE_CONFIG_SSL_KEY là khó khăn. Tôi tìm thấy Beej's Guide to Network Programming rất hữu ích trong việc tìm ra những gì nó nên giống như. Tôi đã có thể sử dụng .NET SocketAddress và sau đó sao chép các byte vào một mảng có thể được sắp xếp lại.
// serialize the endpoint to a SocketAddress and create an array to hold the values. Pin the array.
SocketAddress socketAddress = ipEndPoint.Serialize();
byte[] socketBytes = new byte[socketAddress.Size];
GCHandle handleSocketAddress = GCHandle.Alloc(socketBytes, GCHandleType.Pinned);
// Should copy the first 16 bytes (the SocketAddress has a 32 byte buffer, the size will only be 16, which is what the SOCKADDR accepts
for (int i = 0; i < socketAddress.Size; ++i)
{
socketBytes[i] = socketAddress[i];
}
Tôi đang bỏ phiếu này vì Tomas là người đầu tiên và về cơ bản chúng tôi đã nói điều tương tự. :) –
Liên kết bài viết của Ken Brown giờ đã chết. Có thể tải xuống ở đây mặc dù - http://web.archive.org/web/20121214083056/http://msdn.microsoft.com/en-us/magazine/cc163531.aspx – tjmoore