From: Francis Cianfrocca Date: 2006-09-06T12:37:21+09:00 Subject: Re: C socket to Ruby socket On 9/5/06, Andre Nathan wrote: > Hi! > > On Wed, 2006-09-06 at 01:17 +0900, Kent Sibilev wrote: > > You probably can call Socket.for_fd using rb_funcall. > > I got it to work with an IO: > > rb_funcall(rb_cIO, rb_intern("for_fd"), 1, INT2NUM(socket)); > > However I can't seem to be able to make rb_cSocket visible to my > extension. Any hints on how to do that? You may find this unacceptably ugly, but how about: char buf[100]; snprintf (buf, sizeof(buf)-1, "Socket.for_fd( %d )", socket); rb_eval_string (buf); There was some radio chatter on the core list a few months back about the fact that rb_cSocket is not externed in ruby.h. As I recall the omission is an oversight, not something fundamental. You could also say extern VALUE rb_cSocket; in your extension. I've done that before.