Question

I got error while I was tying to pass structure from RPC client to server. Client calls Output3 procedure.

Definition in IDL:

struct BarStruct
{
  byte a;
  int b;
  byte c;
  char* d;
  char* ddd;
};

void Output3([in] handle_t hBinding, [in, out] struct BarStruct* b);

Generated in header:

struct BarStruct
    {
    byte a;
    int b;
    byte c;
    char *d;
    char *ddd;
    } ;

void Output3( 
    /* [in] */ handle_t hBinding,
    /* [out][in] */ struct BarStruct *b);

implementation in server side:

void Output3(handle_t hBinding, struct BarStruct * b)
{
    std::cout << "a=" << b->a << std::endl;
}

Client side code:

  BarStruct b;
  b.a=10;

  std::cout<<"Output3"<<std::endl ;
  Output3(hBinding, &b);

What might be wrong?

Was it helpful?

Solution

Your structure contains pointer to something, in the specific case pointer to char. When you want to transfer this to another process you have to keep in mind that a pointer is just and address value. When you want to pass the data where the pointer points to you need something different like a conformant array.

The basic idea is that you have to pass the length of the array that is address by the pointer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top