Re: Distributed objects: can't send simple C struct by value
Re: Distributed objects: can't send simple C struct by value
- Subject: Re: Distributed objects: can't send simple C struct by value
- From: Michael Heins <email@hidden>
- Date: Sat, 30 Oct 2004 08:28:41 -0600
On Oct 30, 2004, at 3:25 AM, Wade Tregaskis wrote:
struct _Msg {
int a_fill;
char name[64];
int b_fill;
};
The problem seems to be that the struct is not getting encoded properly in the sender. The encoded object description appears to be correct, and 'a_fill' and the first part of 'name' appears to be correct, but the remainder of the structure is garbage.
Define "first part of 'name'"?
Here is a dump of the struct in the sender just before sending:
BFFFE990: AAAAAAAA 54686973 20697320 6D792074 ....This is my t
BFFFE9A0: 65737420 73747269 6E672077 68696368 est string which
BFFFE9B0: 20676574 73207061 72746C79 20776970 gets partly wip
BFFFE9C0: 6564206F 75742E00 00000000 00000000 ed out..........
BFFFE9D0: 00000000 BBBBBBBB ........
Here it is in the receiver:
BFFFE650: AAAAAAAA 54686973 20697320 6D792074 ....This is my t
BFFFE660: 65737420 73747269 6E672077 A0A03CD4 est string w..<.
BFFFE670: 00528BB0 BFFFE6F0 A0A01234 909FA88C .R.........4....
BFFFE680: BFFFEB00 24022244 909FABF0 02800000 ....$."D........
BFFFE690: 00000020 00000018 ... ....
If I set up authenticationDataForComponents / authenticateComponents delegates on both ends and look at the encoded data in the sender just after encoding the corruption has already happened. I suspect that this has something to do with the way structures are passed by value by the compiler -- I believe that the first part of structs are passed in registers, and the remainder on the stack. I'm guessing that the encoder is not properly taking this into account.
You are correct about byteswapping -- encoded int's etc. do get byteswapped (though that won't be obvious with the test contents I chose above).
Michael Heins AA7XY
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden