From: Eric Wong <normalperson@yhbt.net>
To: ruby.posix.mq@librelist.com
Subject: Re: Using to_io with Marshall.dump
Date: Fri, 7 Jan 2011 09:25:18 -0800 [thread overview]
Message-ID: <20110107172518.GA30966@dcvr.yhbt.net> (raw)
In-Reply-To: AANLkTinPfjenKDsBObLvV8ake4QQ9BfeTU+LoQkm83FV@mail.gmail.com
Iñaki Baz Castillo <ibc@aliax.net> wrote:
> Hi, Ruby Marshal.dump allows writing directly into a IO object:
>
> dump( obj [, anIO] , limit=--1 ) → anIO
> Serializes obj and all descendant objects. If anIO is specified, the
> serialized data will be written to it, otherwise the data will be returned
> as a String.
>
> However it doesn't work with POSIX_MQ#to_io:
>
> Marshal.dump msg, posix_mq.to_io
>
> => ERROR: Errno::EINVAL: #<Errno::EINVAL: Invalid argument> (in `write')
>
> Is it not possible or do I miss something?
POSIX_IO#to_io is a non-standard extension and only works for a few
platforms (Linux and FreeBSD) and was only intended for notification
mechanisms like select/poll/epoll/kqueue. The underlying file
descriptor only accepts the mq_* system calls, and not the normal
read/write/fstat/close deal.
You can try aliasing POSIX_MQ#write to POSIX_MQ#send and just dump the
MQ object, but I think you're better of just dumping a string to it
since the marshalled message can exceed the size limit behind your back
(likewise with YAML/JSON/XML encoders).
--
Eric Wong
next prev parent reply other threads:[~2011-01-07 17:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-07 13:39 Using to_io with Marshall.dump Iñaki Baz Castillo
2011-01-07 17:25 ` Eric Wong [this message]
2011-01-07 18:25 ` Iñaki Baz Castillo
2011-01-07 18:48 ` Eric Wong
2011-01-07 18:52 ` Eric Wong
2011-01-07 20:29 ` Iñaki Baz Castillo
2011-01-07 21:35 ` Eric Wong
2011-01-07 20:25 ` Iñaki Baz Castillo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/ruby_posix_mq/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110107172518.GA30966@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=ruby.posix.mq@librelist.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/ruby_posix_mq.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).