Problems with Marshal

Hi all,

Ruby 1.6.7 on Solaris 9.

I’ve got a client/server app where the client sends a request to the
server, and the server sends back a marshalled object to the client
(using dump). The client then deals with the marshalled object (using
load).

The problem I’m having is that I’m getting inconsistent behavior with
Marshalling. In all cases, I am simply trying to return an array,
usually an array of structs, but sometimes just a plain array.

In the case where I return an array of strings using Mike Hall’s
’filesystem’ module, things work fine.

In the case where I return an array of ProcTable structs using my own
Sys::ProcTable module, I get this error:

“incompatible marshal file format (can’t be read) (TypeError)”

Some google searching indicated that this could be caused by using
different versions of Ruby. That is not the case here, as both client
and server are (currently) just running on my local box.

In the case where I return a simple array (e.g. a = [1,2,3]), I get this
error:

“marshal data too short (ArgumentError)”

Searching google revealed a few posts, but they were all in Japanese
(which I can’t read).

Any help on this topic will be greatly appreciated.

Regards,

Dan

PS - No, I haven’t try XMarshal or AMarshal. Should I?

I've got a client/server app where the client sends a request to the
server, and the server sends back a marshalled object to the client
(using dump). The client then deals with the marshalled object (using
load).

[...]

"incompatible marshal file format (can't be read) (TypeError)"

[...]

"marshal data too short (ArgumentError)"

Have you verified that the string send by the server is the same than the
string received by the client ?

Guy Decoux

“incompatible marshal file format (can’t be read) (TypeError)”

How are you sending and receiving the data?

In the case where I return a simple array (e.g. a = [1,2,3]), I get this
error:

“marshal data too short (ArgumentError)”

put a begin…rescue…end block around this and get it to print out
the data it chokes on.

Dan

    Hugh
···

On Wed, 14 Aug 2002, Daniel Berger wrote: