[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

resolv-replace.rb bug? [WAS: When thread block]

Nathaniel Talbott

9/25/2003 12:25:00 AM

nobu.nokada@softhome.net [mailto:nobu.nokada@softhome.net] wrote:

> Hans Fugal wrote:
> > Is there a list of these sorts of things? I need to know what to
> > expect if I'm going to be able to use ruby for this (soft)
> > real-time application.
>
> File#flock, and some Socket methods do. Use
> resolv-replace.rb for the latter.

Is this intentional?

irb(main):001:0> require 'socket'
=> true
irb(main):002:0> TCPServer::new(55)
=> #<TCPServer:0x2b9ef50>
irb(main):003:0> require 'resolv-replace'
=> true
irb(main):004:0> TCPServer::new(55)
ArgumentError: wrong number of arguments(1 for 2)
from (irb):4:in `new'
from (irb):4

Because of this, using DRb with resolv-replace doesn't work very well. Any
idea as to what is wrong?

Thanks,


Nathaniel

<:((><


3 Answers

nobu.nokada

9/25/2003 1:51:00 AM

0

Hi,

At Thu, 25 Sep 2003 09:24:45 +0900,
Nathaniel Talbott wrote:
> Is this intentional?
>
> irb(main):001:0> require ''socket''
> => true
> irb(main):002:0> TCPServer::new(55)
> => #<TCPServer:0x2b9ef50>
> irb(main):003:0> require ''resolv-replace''
> => true
> irb(main):004:0> TCPServer::new(55)
> ArgumentError: wrong number of arguments(1 for 2)
> from (irb):4:in `new''
> from (irb):4

No, resolv-replace.rb seems not to be 1.8 compliant.

> Because of this, using DRb with resolv-replace doesn''t work very well. Any
> idea as to what is wrong?

Does this work?


Index: lib/resolv-replace.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/lib/resolv-replace.rb,v
retrieving revision 1.1
diff -u -2 -p -r1.1 resolv-replace.rb
--- lib/resolv-replace.rb 30 May 2001 09:10:26 -0000 1.1
+++ lib/resolv-replace.rb 25 Sep 2003 01:49:23 -0000
@@ -1,2 +1,3 @@
+require ''socket''
require ''resolv''

@@ -4,5 +5,5 @@ class BasicSocket
alias original_resolv_send send
def send(mesg, flags, *rest)
- rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length
+ rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty?
original_resolv_send(mesg, flags, *rest)
end
@@ -16,17 +17,18 @@ class << IPSocket
end

-class << TCPSocket
- alias original_resolv_new new
- def new(host, service)
- original_resolv_new(Resolv.getaddress(host).to_s, service)
- end
-
- alias original_resolv_open open
- def open(host, service)
- original_resolv_open(Resolv.getaddress(host).to_s, service)
+class TCPSocket
+ alias original_resolv_initialize initialize
+ def initialize(host, serv, *rest)
+ rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty?
+ original_resolv_initialize(Resolv.getaddress(host).to_s, serv, *rest)
end
end

class UDPSocket
+ alias original_resolv_bind bind
+ def bind(host, port)
+ original_resolv_bind(Resolv.getaddress(host).to_s, port)
+ end
+
alias original_resolv_connect connect
def connect(host, port)
@@ -36,6 +38,13 @@ class UDPSocket
alias original_resolv_send send
def send(mesg, flags, *rest)
- rest[0] = Resolv.getaddress(rest[0]).to_s if 0 < rest.length
+ rest[0] = Resolv.getaddress(rest[0]).to_s unless rest.empty?
original_resolv_send(mesg, flags, *rest)
end
end
+
+class SOCKSSocket
+ alias original_resolv_initialize initialize
+ def initialize(host, serv)
+ original_resolv_initialize(Resolv.getaddress(host).to_s, port)
+ end
+end if defined? SOCKSSocket


--
Nobu Nakada

Tanaka Akira

9/26/2003 5:56:00 AM

0

In article <200309250150.h8P1ow2s008367@sharui.nakada.kanuma.tochigi.jp>,
nobu.nokada@softhome.net writes:

> No, resolv-replace.rb seems not to be 1.8 compliant.

Please commit it.
--
Tanaka Akira

Mauricio Webster

11/14/2013 2:20:00 AM

0

An ultra-left LOSER. Like most socially misfit DemocRATs, Bret lives
alone in a one-room apartment:

Bret E. Cahill (56+)
649 Main St, Apt 226
Brawley, CA 92227

Bret tried to sue the gov't and got stomped on like an insect. Ever
since that crushing humiliation he has hated himself, everybody else,
and America.

BRET E. CAHILL, PETITIONER
v.
UNITED STATES DEPARTMENT OF LABOR, ET AL....
CONCLUSION
The petition for a writ of certiorari should be denied.
http://www.justice.gov/osg/briefs/1995/w9...

Note that when you reply to a Proven Liar you encourage them to
continue lying.

[][][][][][]
The DemocRATs Hall Of Shame asks "Why do you always LIE?"

[Courtesy of Buster Norris]

On Wed, 13 Mar 2013 21:31:52 -0700 (PDT), Bret Cahill
<Bret_E_Cahill@yahoo.com> wrote:
>> http://www.youtube.com/watch?v=Li0no7O9zmE&featur...
>That guy is making one sixth of average mean income which is now over
>$70/hour.

LIAR!!!!!!!!!!!!!!!!!!

Total population
Full-time workers, age 25-64
Overall Median: $39,509/yr. = $19.00/hr.
http://en.wikipedia.org/wiki/Personal_income_in_the_Uni...

Posted on behalf of:
The DemocRATs Hall of Shame!