/*
 * call-seq:
 *      io -> IO
 *
 * Returns an +IO+ handle representing the connection to Spread. The
 * Spread "mailbox" is actually a file descriptor; I'm not sure if
 * this is documented anywhere, but it seems to be relied upon by a
 * number of things.
 *
 * Note that it is *not* safe to do much with the IO object; in
 * particular, reading or writing to it is certainly not wise. This
 * method is intended primarily to allow the use of Kernel#select to
 * wait for Spread activity.
 */
static VALUE
spconn_io(VALUE obj)
{
    struct SpreadConnection *sp_conn;

    Data_Get_Struct(obj, struct SpreadConnection, sp_conn);
    if (NIL_P(sp_conn->rb_fd))
    {
        /* Construct a new wrapper */
        VALUE fd = INT2NUM(sp_conn->mbox);
        sp_conn->rb_fd =  rb_class_new_instance(1, &fd, rb_cIO);
    }

    return sp_conn->rb_fd;
}