# Solaris door Ruby bindings

**URL:** <https://www.ruby-forum.com/t/solaris-door-ruby-bindings/106996>\
**Category:** Ruby\
**Created:** [June 16, 2007, 8:26am UTC](https://www.ruby-forum.com/t/solaris-door-ruby-bindings/106996 "2007-06-16T08:26:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Banzai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@Banzai](https://www.ruby-forum.com/u/Banzai)\
**Post date:** [June 16, 2007, 8:26am UTC](https://www.ruby-forum.com/t/solaris-door-ruby-bindings/106996/1 "2007-06-16T08:26:59Z")

</div>

I’m writing a ruby extension in C to the Solaris door library. The  
door library provides for fast IPC locally on Solaris.

I wonder if such a thing is of interest to you. If you are interested  
(or not), I’d appreciate your input.

1. Right now, it looks like this:

## server process

require ‘door’  
class Door  
def func(arg=0)  
return arg\*\*2  
end  
end

d = Door.new("/path/to/door", “func”)

## client process

require ‘door’  
d = Door.new("/path/to/door")

answer = d.call(2) # =\> 4

Is it more convenient to say:  
d = Door.new(:path =\> “/path/to/door”, :proc =\> “func”)  
?

Which is more ruby-like?

Perhaps I can support both by checking the type of the first VALUE…

1. Is it OK to distribute this extension under a license other than  
CDDL (this is the Solaris license), say GPL or whatnot? I’m just using  
the API.

Since I used the code from ruby source (to implement, e.g.,  
“File.new(path).door?”), I think I’ll have to use GPL, which is  
incompatible with CDDL, from what I read.

1. If there’s enough interest, I would like to register the project  
with Rubyforge under “door” or “ruby-door” or something. Can you think  
of a better name?

---

<div class="post-metadata">

**Author:** ![Banzai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@Banzai](https://www.ruby-forum.com/u/Banzai)\
**Post date:** [June 16, 2007, 10:09am UTC](https://www.ruby-forum.com/t/solaris-door-ruby-bindings/106996/2 "2007-06-16T10:09:07Z")

</div>

On 6/16/07, Banzai [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> …  
> d = Door.new(“/path/to/door”, “func”)  
> Is it more convenient to say:  
> d = Door.new(:path =\> “/path/to/door”, :proc =\> “func”)

From my experience the most Ruby-like way of doing this would be  
d = Door.new(“/path/to/door”) { |arg| arg \*\* 2 }

You can implement it like this

class Door  
def initialize(path, &block)  
# var named block is now a Proc object  
@block = block  
end  
end

Regards,

- Erwin

---

<div class="post-metadata">

**Author:** ![Banzai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@Banzai](https://www.ruby-forum.com/u/Banzai)\
**Post date:** [June 17, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/solaris-door-ruby-bindings/106996/3 "2007-06-17T17:10:34Z")

</div>

On 2007-06-16 03:07:57 -0500, “Erwin A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
said:

> class Door  
> def initialize(path, &block)  
> # var named block is now a Proc object  
> @block = block  
> end  
> end
> 
> Regards,
> 
> - Erwin

Thank you for your input, Erwin.

Remember that my extension is written in C, so the implementation would  
be a bit more involved. 🙂

I do like the idea… But, I think Door should be a subclass of File,  
and File doesn’t like a code block for an argument, and I’ll get this  
warning:

warning: Door::new() does not take block; use Door::open() instead

This warning comes from rb\_io\_s\_new() in io.c, so I don’t think I can  
suppress it if I say:

rb\_define\_class(“Door”, rb\_cFile);
