Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Stupid Problem

Thread Tools

Stupid Problem
Posts: n/a
I'm a total newb as you'll find out. But regardless, i have a question.
I run the code below:

It locks up (doesn't do anything).
If i remove the while 1 and 'end' but leave the code between it works
It must be in how i'm envisioning how the thread works. I'm a java
programmer and this seems correct. Create the thread, define it's
works then start the thread. The call to start should return and not
block. I'm not sure what it's doing when i run the code with the
'while' statement.

Thanks for your help.

#load "ListenerList.rb"
require "socket"

class MovingPartsServer

def initialize()
# do nothing yet
#@listeners =;
# initialize the UDP socket
puts " Open Socket"
@socket =
puts "Socket Created : "
puts @socket
@socket.bind(nil, 10003)
puts "bound"


def run()
puts "run"
@sThread = { |server|
while 1
puts "in thread"
rcv = @socket.recvfrom(64)
puts rcv
# @listeners.AddListener rcv[0]
# puts @listeners
return @sThread


puts "Start"
server =;
puts "Start Server Thread"
sThread =;

puts "start client""ad hoc", 0, 'localhost', 10003)
puts "end client"

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
stupid question...waiting for a stupid answer Brandon McCombs Java 4 08-28-2006 06:57 PM
Stupid question. Please, only stupid responders. If you're not sureif you're stupid, you probably aren't. =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-18-2005 05:11 AM
stupid stupid stupid kpg MCSE 17 11-26-2004 02:59 PM
stupid test questions and stupid awnsers in Measureup 70-320 test john MCAD 0 10-13-2004 11:43 PM
Stupid is as Stupid Does! Michael P Gabriel Digital Photography 3 06-26-2004 12:49 PM