From: Nat Pryce Date: 2001-08-08T19:28:12+09:00 Subject: [ruby-talk:19369] Re: ANNOUNCE: socket options library v0.1 From: "A Bull in the China Shop of Life" > At 08:16 AM 8/7/01 +0900, Nat Pryce spewed forth: > >I have written this as a proof-of-concept for an RCR. What do people think > >about extending the Ruby socket classes with methods like this written in C? > >Sockopt is available from http://www.b13media.com/dev/ruby/index.html. > I can't speak to this extension's rightness or wrongness WRT the Ruby core, > but as an end user this would certainly be a very cool addition. > > I've been wishing for a mechanism to experiment with SO_LINGER which seems > to cause the 90,000 sockets sitting around waiting to die behavior UNIX > admins see with some daemons. In porting the package to Linux I've come to the conclusion that it's basically impossible to implement in a cross platform manner with Ruby's current sockets API. Firstly, Ruby sockets emit a lot of necessary constants (the IPPROTO... constants for example) from the Socket class, which therefore need to be defined at the socket level -- this is impossible to do without coding platform specifics into the class. Secondly, the strings passed to socket options need to be packed in the correct byte order and encoding for the platform, taking into account the packing of field structures expected by the operating system and so forth; again impossible to do in a cross platform manner. I will probably have to reimplement the package in C. Cheers, Nat.