how to convert native strusture to unsigned char buffer __gc[]

S

Sergey Muschin

Hi there,

i need to send a socket message to TCP socket server. Server has been
implemented
with VC 6.0 and expects from client the message in this format

typedef struct {
int msg_nbr; // Message number from list below
// Profile data
int iPar1;
int iPar2;
char chPar1[32];
char chPar2[32];

}EngAPI_def;

Now, in .NET Framework Class Library method Send of the class Socket wants
unsigned char buffer __gc[]

as a parametr.

How do i convert/emulate this native structure in my managed C++ code ?
I am out of any ideas :(((

Regards,
Sergey Muschin
 
S

Sergey Muschin

Looks like nobody to help. So, i answer this myself :))

uEngAPI_def uEngAPI;
...........................
...........................
BYTE* buf = (BYTE*)&uEngAPI;
int iLen = sizeof(uEngAPI_def);
Byte byteArray[] = new Byte[iLen];
Marshal::Copy((IntPtr)buf,byteArray, 0, iLen);
...............................

now You have a managed array of bytes

Regards,
Sergey Muschin

i need to send a socket message to TCP socket server. Server has been
implemented
with VC 6.0 and expects from client the message in this format
.................................
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top