I have an external dll in c++ that I'm trying to Interop with C#. I have most of the function calls exposed, but I'm scrating my head on how to do this one. I can't figure out how to define and pass the sockaddr as a parameter.
The unmanaged code has this .h:
struct sockaddr_storage my_ip);
The example c++ code given to me is this:
struct sockaddr_storage my_ip;
ip_size = sizeof(my_ip);
(struct sockaddr *)&my_ip,
int ret=MY_Connection(my_handle, my_ip);
And I've only gotten this far in C#:
[DllImportAttribute("my.dll", EntryPoint = "MY_Connection", CallingConvention = CallingConvention.Cdecl)]
public static extern int MY_Connection(System.IntPtr my_handle,
???? And this is where I'm stuck. ????
IntPtr my_handle=new IntPtr();
int ret=MY_Connection(my_handle, ?????? );
How can I represent the socket structure? I know I'll have to do something like:
[StructLayout(LayoutKind.Explicit, Size = ???)]
public struct SOCKADDR_STORAGE
How would I pass the structure to the function? I'm a little confused.
View Complete Post