[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby Bug? Windows and UDPSocket and Errno:ENOTCONN

John Carter

9/10/2008 4:15:00 AM

If I have a pair of Win2k Ruby processes bouncing UDP packets back and
forth...

After awhile one of them dies with Errno::ENOTCONN

The code works under Linux but not under Win2k, neither on ruby-1.8.6
nor 1.8.7.

Any guesses? Suggestions? Workarounds?





John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand

======================================================================

#!/usr/bin/ruby -w
STDOUT.sync = true

require 'socket'


SERVER_PORT = 7272
CLIENT_PORT = 7373

SERVER_HOST = 'localhost'
CLIENT_HOST = 'localhost'

PACKET_LENGTH = 64

SLEEP_TIME = 3 #seconds

MESSAGE = "I say, boy, I resemble that remark!"

class AbstractDaemon

def initialize(to_host, send_port, recv_port)
@send_port = send_port
@recv_port = recv_port
@host = to_host
@recv_socket = UDPSocket.new
print "Listening on port: #{@recv_port}..."
@recv_socket.bind(0, @recv_port)
puts 'ok'
@send_socket = UDPSocket.new
print "Listening on port: #{@send_port}..."
@send_socket.connect(0, @send_port)
puts 'ok'
do_stuff
end

def do_stuff
raise Exception.new("Dummy method not implemented")
end

def send
puts "Sending message: #{MESSAGE}"
@send_socket.syswrite(MESSAGE)
end

def receive
packet,address = *@recv_socket.recvfrom(PACKET_LENGTH)
puts "Received message: #{packet}"
end

def pause
print "Sleeping"
SLEEP_TIME.times do
print '.'
sleep(1)
end
puts ""
end


end

class Server < AbstractDaemon

def initialize
super(CLIENT_HOST, CLIENT_PORT, SERVER_PORT)
end

def do_stuff
while true
receive
send
# pause
end
end

end

class Client < AbstractDaemon

def initialize
super(SERVER_HOST, SERVER_PORT, CLIENT_PORT)
end

def do_stuff
while true
send
receive
# pause
end
end

end

if ARGV[0] == 'server'
Server.new
elsif ARGV[0] == 'client'
Client.new
else
puts "Usage: #{$0} <client | server>"
end


9 Answers

Harold Burton

10/10/2007 3:41:00 AM

0

In article <XJXOi.40925$RX.4366@newssvr11.news.prodigy.net>,
"Al E. Gator" <ho.ho@yahoo.net> wrote:


> I wonder what the hell makes you think I should be
> paying to send your retarded, ignorant,
> cross eyed, autistic, perverted and doomed...


Ah, projecting again, eh? Snicker.

Skippy

10/10/2007 3:45:00 AM

0


"MoveOn.DemocrapDailyKooK's" <Democrapk00ks@DNC.org> wrote in message
news:89GdnfJZXNYZpJHanZ2dnUVZ_i2dnZ2d@comcast.com...
> The "Not So Poor" 12 Year Old Who Rebutted Bush on SCHIP Veto
> Multiple, Baltimore Sun ^ | 10-07-07 |
>
>

Complete bullshit.

They purchased the house YEARS ago when it was in a modest neighborhood that
has since been gentrified.

The two children go to the private school ONLY because the school charges
them only $500 per year for tuition because of their medical conditions that
resulted from an automobile accident.

But, hey, don't let the facts get in the way of your sliming a decent
family.

You're lower than whale shit.



Al E. Gator

10/10/2007 6:41:00 AM

0


"Harold Burton" <hal.i.burton@hotmail.com> wrote in message
news:hal.i.burton-AA0BDC.23412109102007@comcast.dca.giganews.com...
> In article <XJXOi.40925$RX.4366@newssvr11.news.prodigy.net>,
> "Al E. Gator" <ho.ho@yahoo.net> wrote:
>
>
>> I wonder what the hell makes you think I should be
>> paying to send your retarded, ignorant,
>> cross eyed, autistic, perverted and doomed...
>
>
> Ah, projecting again, eh? Snicker.

right gomer, looks like your simple and feeble, one dimensional
thinking goober brain can't deal with truth,facts, or logic

that little bit of simple logic just overwhelmed your stupid ass didn't it
you dumb
fucking cocksucking hillbilly faggot bitch

just shut the hell up with your simple minded hillbilly bullshit gomer,

you lame brain, hair brain redneck, dicksucking nascar watching, men's room
addickted
fuckups always resort to that lame old :


"yall mus bea prOjecting again" bullshit, or some other stupid, inane
hillbillism,

you need to realize there you broke back, lame ass gutless faggot, that most
if not all of the people in the world
are smarter than you hillbillies, and that typical hillbilly shit talk only
works on other retarded or brain damaged, dicksucking
nascar watching, fat blubber butt hillbillies like those bush and cheney
cocksuckers

give up gomer, wave that white flag, you hillbillies should be used to it
with the considerable experience
you have LOSING, going back to the days of the traitor cocksucker robert e.
lee,

where is that bitch buried gomer, we need to dig that faggot losing traitor
up and hang him on the white house lawn to be a lesson
to all you losing, failing, hillbilly fuckups


LMAO, another gomer bites the dust, careful he can and will still bite your
wiener, their favorite sport


MoveOn.DemocrapDailyK00k's

10/10/2007 12:18:00 PM

0


"Joe S." <noone@nowhere.net> wrote in message
news:fehhva02fj7@news5.newsguy.com...
>
> "MoveOn.DemocrapDailyKooK's" <Democrapk00ks@DNC.org> wrote in message
> news:89GdnfJZXNYZpJHanZ2dnUVZ_i2dnZ2d@comcast.com...
Media Fail at Fact Checking on 12 Year Old Voice of SCHIP; Blogs Pick Up
Slack
By John Stephenson | October 7, 2007 - 21:36 ET
The media piled on when President Bush used his veto pen on this children's
health insurance bill. They tried to drop the absolute moral authority bomb
on it big time and paint him as not caring about children. Now it looks like
a little backfire is on the horizon.

On September 29th, 12 year old Graeme Frost of Maryland got to do the
Democrats' radio address, in which he told his story of how he and his
sister were seriously injured in a car accident, and if it hadn't been for
SCHIP, they wouldn't be here today. The Baltimore Sun did a story on the
family, in which it stated the family couldn't get health insurance through
their work.

"Bonnie Frost works for a medical publishing firm; her husband, Halsey, is
a woodworker. They are raising their four children on combined income of
about $45,000 a year. Neither gets health insurance through work."


There were many others in the media that swallowed the story whole with its
hook. All of them were missing greatly in one major thing, facts.

Freerepublic's icwhatudo, managed to find plenty of missing facts using
google:

"First, Mr. Halsey Frost, Graeme's father, owns his own woodworking design
studio, Frostworks, so his claim that he can't get health insurance through
work is shockingly deceptive. He chooses not to get health care for his
family. Second, Graeme and his sister Gemma attend the very exclusive Park
School, which has a tuition of $20,000 a year, per child. Third, they live
in a 3,000+ square foot home in a neighborhood with smaller homes that are
selling for at least $400,000. "


Dan Collins concludes:

"I'm glad little Graham and his family were able to get help, and I hope
he reaches full rehabilitation. But perhaps the Democrats ought to take more
care in the spokespeople they choose, if they wish to tug at our
heartstrings."


Then again, as Mark Steyn says:

"But who needs facts when you've got the human-interest angle sewn up?"


Roundup of blogosphere reactions at Stop The ACLU

-John Stephenson is editor of Stop The ACLU



Al E. Gator

10/10/2007 4:24:00 PM

0


"MoveOn.DemocrapDailyKooK's" <Democrapk00ks@DNC.org> wrote in message

wow you hillbilly cocksuckers really got something there goober,

damn, all 10 million of those kids without health insurance must
go to private schools, and have parents that own businesses

damn greedy varmints


Harold Burton

10/10/2007 6:17:00 PM

0

In article <Ct_Oi.57413$Um6.18037@newssvr12.news.prodigy.net>,
"Al E. Gator" <ho.ho@yahoo.net> wrote:


> right gomer, looks like your simple and feeble, one dimensional
> thinking goober brain can't deal with truth,facts, or logic
>
> that little bit of simple logic just overwhelmed your stupid ass didn't it
> you dumb
> fucking cocksucking hillbilly faggot bitch
>
> just shut the hell up with your simple minded hillbilly bullshit gomer,
>
> you lame brain, hair brain redneck, dicksucking nascar watching, men's room
> addickted
> fuckups always resort to that lame old :
>
>
> "yall mus bea prOjecting again" bullshit, or some other stupid, inane
> hillbillism,
>
> you need to realize there you broke back, lame ass gutless faggot, that most
> if not all of the people in the world
> are smarter than you hillbillies, and that typical hillbilly shit talk only
> works on other retarded or brain damaged, dicksucking
> nascar watching, fat blubber butt hillbillies like those bush and cheney
> cocksuckers
>
> give up gomer, wave that white flag, you hillbillies should be used to it
> with the considerable experience
> you have LOSING, going back to the days of the traitor cocksucker robert e.
> lee,
>
> where is that bitch buried gomer, we need to dig that faggot losing traitor
> up and hang him on the white house lawn to be a lesson
> to all you losing, failing, hillbilly fuckups
>
>
> LMAO, another gomer bites the dust, careful he can and will still bite your
> wiener, their favorite sport




Ya poke him and he squeals. Snicker.

MoveOn.DemocrapDailyK00k's

10/11/2007 3:54:00 AM

0


"General Gator" <ho.ho@yahoo.net> wrote in message
news:L07Pi.1372$Pv2.415@newssvr23.news.prodigy.net...
>
> "MoveOn.DemocrapDailyKooK's" <Democrapk00ks@DNC.org> wrote in message
>
> wow you hillbilly cocksuckers really got something there goober,
>
> damn, all 10 million of those kids without health insurance
===============

What 10 Million without health insurance? They have been covered for 10
years you lying pile of monkey maggot slime.

the Democrat congressional majority will attempt to raise taxes and
spending, all to make a down-payment on HillaryCare 2.0. socialized medicine
bill they will pass this week increases cigarette taxes by $0.91 per pack,
while enrolling 25-year old "children" and adults from households making up
to $82,000 per year.
http://article.nationalreview.com/?q=OTZlZmJlNDkxODBlY2ViNThlOTJkZmRlMD...


Bill Kelly

9/10/2008 6:26:00 AM

0


From: "John Carter" <john.carter@tait.co.nz>
>
> If I have a pair of Win2k Ruby processes bouncing UDP packets back and
> forth...
>
> After awhile one of them dies with Errno::ENOTCONN
>
> The code works under Linux but not under Win2k, neither on ruby-1.8.6
> nor 1.8.7.
>
> Any guesses? Suggestions? Workarounds?

Replaced connect/syswrite, with send:

--- john_carter_udp_enotconn.orig.rb 2008-09-09 23:27:04.491375000 -0700
+++ john_carter_udp_enotconn.rb 2008-09-09 23:27:50.975750000 -0700
@@ -28,7 +28,6 @@
puts 'ok'
@send_socket = UDPSocket.new
print "Listening on port: #{@send_port}..."
- @send_socket.connect(0, @send_port)
puts 'ok'
do_stuff
end
@@ -39,7 +38,7 @@

def send
puts "Sending message: #{MESSAGE}"
- @send_socket.syswrite(MESSAGE)
+ @send_socket.send(MESSAGE, 0, @host, @send_port)
end

def receive




Hope this helps,

Bill



John Carter

9/11/2008 12:49:00 AM

0

> From: "John Carter" <john.carter@tait.co.nz>
>>
>> If I have a pair of Win2k Ruby processes bouncing UDP packets back and
>> forth...
>>
>> After awhile one of them dies with Errno::ENOTCONN
>>
>> The code works under Linux but not under Win2k, neither on ruby-1.8.6
>> nor 1.8.7.
>>
>> Any guesses? Suggestions? Workarounds?

On Wed, 10 Sep 2008, Bill Kelly replied:
> Replaced connect/syswrite, with send:

I thought, hmm, I'm pretty sure thats what I tried first....

Anyhoo, I'll try your suggestion and...

...it worked!

> Hope this helps,

So I went back to the original code and saw we had...
UDPSocket.open.send

Ping! Light goes on! Everytime we do UDPSocket.open we open an fd and
don't close it.

The mystik Errno::ENOTCONN arises because the open failed (silently)
because we had run out of file handles!

Thanks!

John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand