Hi, How to make a socket to listen a port and make it multi-thread (one thread per client connection) with JRUBY ? Anyone have examples or can give me a code? -- Atenciosamente, Paulo Coutinho. Blog: www.prsolucoes.com/blog Site: www.prsolucoes.com Msn: paulo-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ruby has a Thread class. t = Thread.new do ... end Depending on whether you want to act as a socket server you can make use of ruby''s TCPServer, or if you want to connect to a (socket) server there''s the TCPSocket class. What exactly do you want to do, what is your use case? Why do you need (long-living?) threads (per session or, even worse, "click"?)? Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README) or delayed_job (http://github.com/tobi/delayed_job) suffice? Hope this helps On 3 Dez., 07:56, Paulo Coutinho <pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote:> Hi, > > How to make a socket to listen a port and make it multi-thread (one thread > per client connection) with JRUBY ? > > Anyone have examples or can give me a code? > > -- > Atenciosamente, > Paulo Coutinho. > Blog:www.prsolucoes.com/blog > Site:www.prsolucoes.com > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have a game server to my game in flash, but the server is in pure java, using sockets. So i want port it do jruby, because i think its very fast and easy to make database operations and all ruby facilities. What you think about it? Is a good solution? 2009/12/4 Clemens <clemens.wyss-7fY5B7ekypAfv37vnLkPlQ@public.gmane.org>> Ruby has a Thread class. > t = Thread.new do > ... > end > > Depending on whether you want to act as a socket server you can make > use of ruby''s TCPServer, or if you want to connect to a (socket) > server there''s the TCPSocket class. > > What exactly do you want to do, what is your use case? Why do you need > (long-living?) threads (per session or, even worse, "click"?)? > Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README) or > delayed_job (http://github.com/tobi/delayed_job) suffice? > > Hope this helps > > On 3 Dez., 07:56, Paulo Coutinho <pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote: > > Hi, > > > > How to make a socket to listen a port and make it multi-thread (one > thread > > per client connection) with JRUBY ? > > > > Anyone have examples or can give me a code? > > > > -- > > Atenciosamente, > > Paulo Coutinho. > > Blog:www.prsolucoes.com/blog > > Site:www.prsolucoes.com > > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- Atenciosamente, Paulo Coutinho. Blog: www.prsolucoes.com/blog Site: www.prsolucoes.com Msn: paulo-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have make a sample, to test ruby thread, but no success. it run like a
single thread.
t = Thread.new() do |n|
puts "==>START THREAD"
sleep 15
puts "==>END THREAD"
end
t.join
arr = [1,2,3,4,5,6,7,8,9,10]
for item in arr
puts "==> Show item: " + item.to_s
sleep 1
end
Thx.
2009/12/4 Paulo Coutinho <paulo-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org>
> I have a game server to my game in flash, but the server is in pure java,
> using sockets.
>
> So i want port it do jruby, because i think its very fast and easy to make
> database operations and all ruby facilities.
>
> What you think about it? Is a good solution?
>
>
>
> 2009/12/4 Clemens
<clemens.wyss-7fY5B7ekypAfv37vnLkPlQ@public.gmane.org>
>
> Ruby has a Thread class.
>> t = Thread.new do
>> ...
>> end
>>
>> Depending on whether you want to act as a socket server you can make
>> use of ruby''s TCPServer, or if you want to connect to a
(socket)
>> server there''s the TCPSocket class.
>>
>> What exactly do you want to do, what is your use case? Why do you need
>> (long-living?) threads (per session or, even worse,
"click"?)?
>> Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README) or
>> delayed_job (http://github.com/tobi/delayed_job) suffice?
>>
>> Hope this helps
>>
>> On 3 Dez., 07:56, Paulo Coutinho
<pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote:
>> > Hi,
>> >
>> > How to make a socket to listen a port and make it multi-thread
(one
>> thread
>> > per client connection) with JRUBY ?
>> >
>> > Anyone have examples or can give me a code?
>> >
>> > --
>> > Atenciosamente,
>> > Paulo Coutinho.
>> > Blog:www.prsolucoes.com/blog
>> > Site:www.prsolucoes.com
>> > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org
>>
>> --
>>
>> You received this message because you are subscribed to the Google
Groups
>> "Ruby on Rails: Talk" group.
>> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To unsubscribe from this group, send email to
>>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>>
>
>
> --
> Atenciosamente,
> Paulo Coutinho.
> Blog: www.prsolucoes.com/blog
> Site: www.prsolucoes.com
> Msn: paulo-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org
>
--
Atenciosamente,
Paulo Coutinho.
Blog: www.prsolucoes.com/blog
Site: www.prsolucoes.com
Msn: paulo-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
the "t.join" synchronizes the spawned thread with the main thread
(rendez-vous)
--------------
t = Thread.new do
puts "==>START THREAD"
sleep 15
puts "==>END THREAD"
end
arr = [1,2,3,4,5,6,7,8,9,10]
for item in arr
puts "==> Show item: " + item.to_s
sleep 1
end
t.join # <- move it here, otherwise the spawned thread is bein
termintaed with the main program...
-------------
On 5 Dez., 00:06, Paulo Coutinho
<pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org>
wrote:> I have make a sample, to test ruby thread, but no success. it run like a
> single thread.
>
> t = Thread.new() do |n|
> puts "==>START THREAD"
> sleep 15
> puts "==>END THREAD"
> end
>
> t.join
>
> arr = [1,2,3,4,5,6,7,8,9,10]
> for item in arr
> puts "==> Show item: " + item.to_s
> sleep 1
> end
>
> Thx.
>
> 2009/12/4 Paulo Coutinho
<pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org>
>
>
>
>
>
> > I have a game server to my game in flash, but the server is in pure
java,
> > using sockets.
>
> > So i want port it do jruby, because i think its very fast and easy to
make
> > database operations and all ruby facilities.
>
> > What you think about it? Is a good solution?
>
> > 2009/12/4 Clemens
<clemens.w...-7fY5B7ekypAfv37vnLkPlQ@public.gmane.org>
>
> > Ruby has a Thread class.
> >> t = Thread.new do
> >> ...
> >> end
>
> >> Depending on whether you want to act as a socket server you can
make
> >> use of ruby''s TCPServer, or if you want to connect to a
(socket)
> >> server there''s the TCPSocket class.
>
> >> What exactly do you want to do, what is your use case? Why do you
need
> >> (long-living?) threads (per session or, even worse,
"click"?)?
> >> Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README)
or
> >> delayed_job (http://github.com/tobi/delayed_job) suffice?
>
> >> Hope this helps
>
> >> On 3 Dez., 07:56, Paulo Coutinho
<pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote:
> >> > Hi,
>
> >> > How to make a socket to listen a port and make it
multi-thread (one
> >> thread
> >> > per client connection) with JRUBY ?
>
> >> > Anyone have examples or can give me a code?
>
> >> > --
> >> > Atenciosamente,
> >> > Paulo Coutinho.
> >> > Blog:www.prsolucoes.com/blog
> >> > Site:www.prsolucoes.com
> >> > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org
>
> >> --
>
> >> You received this message because you are subscribed to the Google
Groups
> >> "Ruby on Rails: Talk" group.
> >> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> >> To unsubscribe from this group, send email to
> >>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > Atenciosamente,
> > Paulo Coutinho.
> > Blog:www.prsolucoes.com/blog
> > Site:www.prsolucoes.com
> > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org
>
> --
> Atenciosamente,
> Paulo Coutinho.
> Blog:www.prsolucoes.com/blog
> Site:www.prsolucoes.com
> Msn: pa...-QE/7f1ia5mRu4uuhH+UX+w@public.gmane.org Zitierten Text
ausblenden -
>
> - Zitierten Text anzeigen -
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
-> http://www.tutorialspoint.com/ruby/ruby_socket_programming.htm maybe this (in particular the "Multi-Client TCP Servers"-section) helps? BTW: what''s this to do with rails? ;-) On 5 Dez., 00:04, Paulo Coutinho <pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote:> I have a game server to my game in flash, but the server is in pure java, > using sockets. > > So i want port it do jruby, because i think its very fast and easy to make > database operations and all ruby facilities. > > What you think about it? Is a good solution? > > 2009/12/4 Clemens <clemens.w...-7fY5B7ekypAfv37vnLkPlQ@public.gmane.org> > > > > > > > Ruby has a Thread class. > > t = Thread.new do > > ... > > end > > > Depending on whether you want to act as a socket server you can make > > use of ruby''s TCPServer, or if you want to connect to a (socket) > > server there''s the TCPSocket class. > > > What exactly do you want to do, what is your use case? Why do you need > > (long-living?) threads (per session or, even worse, "click"?)? > > Maybe BJ (http://codeforpeople.rubyforge.org/svn/bj/trunk/README) or > > delayed_job (http://github.com/tobi/delayed_job) suffice? > > > Hope this helps > > > On 3 Dez., 07:56, Paulo Coutinho <pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org> wrote: > > > Hi, > > > > How to make a socket to listen a port and make it multi-thread (one > > thread > > > per client connection) with JRUBY ? > > > > Anyone have examples or can give me a code? > > > > -- > > > Atenciosamente, > > > Paulo Coutinho. > > > Blog:www.prsolucoes.com/blog > > > Site:www.prsolucoes.com > > > Msn: pa...-QE/7f1ia5mR0ubjbjo6WXg@public.gmane.org > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > Atenciosamente, > Paulo Coutinho. > Blog:www.prsolucoes.com/blog > Site:www.prsolucoes.com > Msn: pa...-QE/7f1ia5mRu4uuhH+UX+w@public.gmane.org Zitierten Text ausblenden - > > - Zitierten Text anzeigen --- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.