Forum: Ruby Stupid Problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2006-03-24 02:14
(Received via mailing list)
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"
This topic is locked and can not be replied to.