List Info

Thread: Two examples not running as expected




Two examples not running as expected
user name
2007-05-08 00:27:26
Hi,
I'm having some trouble running two EM examples.
I'm using the EM gem version 0.7.0
ruby --version:
ruby 1.8.5 (2006-08-25) [i586-linux]

Operating system:
uname -a:
Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri Mar 2
13:51:59 UTC
2007 i686 i686 i386 GNU/Linux

the code example is below.  I have inserted my IP address,
as shown by
ifconfig -a.
If I use the code as below the ruby console is empty.

# ###### start code snippet ######

require 'rubygems'
require 'eventmachine'

module EchoServer
  def receive_data data
    send_data ">>>you sent: #"
    close_connection if data =~ /quit/i
  end
end

EventMachine::run {
  EventMachine::start_server "192.168.1.1", 8100,
EchoServer
}

# ###### end code snippet ######

If I use the port 8081 I get the following in the ruby
console:

/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
`start_tcp_server': no acceptor (RuntimeError)
	from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
`start_server'
	from lib/em_example.rb:12
	from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
`call'
	from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
`event_callback'
	from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
`run_machine'
	from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
`run'
	from lib/em_example.rb:11

I have also tried to run the code example shown in this
post:
http://rubyforge.org/pipermail/eventmachine
-talk/2006-May/000060.html

When I do, all I see in the console is (spaced 5 seconds
apart):
[]
[]
[]
.....

I have tried the above two examples using 127.0.0.1 and a
fully
qualified domain name - all give the same result.
Any suggestions about what I might have done or configured
incorrectly?

Thanks in advance
Mark
_______________________________________________
Eventmachine-talk mailing list
Eventmachine-talkrubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

Re: Two examples not running as expected
user name
2007-05-08 01:27:34
Hi,
Please disregard the email below.
I've worked out what my mistake was - all works as
expected!
Apologies for the mail clutter
Mark



On 5/8/07, Mark Van De Vyver <mvyvergmail.com> wrote:
> Hi,
> I'm having some trouble running two EM examples.
> I'm using the EM gem version 0.7.0
> ruby --version:
> ruby 1.8.5 (2006-08-25) [i586-linux]
>
> Operating system:
> uname -a:
> Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri Mar 2
13:51:59 UTC
> 2007 i686 i686 i386 GNU/Linux
>
> the code example is below.  I have inserted my IP
address, as shown by
> ifconfig -a.
> If I use the code as below the ruby console is empty.
>
> # ###### start code snippet ######
>
> require 'rubygems'
> require 'eventmachine'
>
> module EchoServer
>   def receive_data data
>     send_data ">>>you sent:
#"
>     close_connection if data =~ /quit/i
>   end
> end
>
> EventMachine::run {
>   EventMachine::start_server "192.168.1.1",
8100, EchoServer
> }
>
> # ###### end code snippet ######
>
> If I use the port 8081 I get the following in the ruby
console:
>
>
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
> `start_tcp_server': no acceptor (RuntimeError)
>         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
> `start_server'
>         from lib/em_example.rb:12
>         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
> `call'
>         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
> `event_callback'
>         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
> `run_machine'
>         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
> `run'
>         from lib/em_example.rb:11
>
> I have also tried to run the code example shown in this
post:
> http://rubyforge.org/pipermail/eventmachine
-talk/2006-May/000060.html
>
> When I do, all I see in the console is (spaced 5
seconds apart):
> []
> []
> []
> .....
>
> I have tried the above two examples using 127.0.0.1 and
a fully
> qualified domain name - all give the same result.
> Any suggestions about what I might have done or
configured incorrectly?
>
> Thanks in advance
> Mark
>
_______________________________________________
Eventmachine-talk mailing list
Eventmachine-talkrubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

Re: Two examples not running as expected
user name
2007-06-01 19:33:19
Hi Eugueny, (cc list)
Good question.  Took me some time to think back....
I've taken the liberty of cc'ing the list in case anyone
else comes
along this 'path'/thread.

I think this is what happened.

Regarding my first mail in this thread:
The error message was (I think) due to the port being in
use(?)

Regarding:
 http://rubyforge.org/pipermail/eventmachine
-talk/2006-May/000060.html

Well. I understood so little of what was happening in EM
that what I
thought was unexpected behavior was, in fact, perfect
behavior...
The sequence of printed '[]' reflect the fact that no client
has yet
connected to that server 

The following example helped me work out what was happening.
 From
this I added snippets from the code in
http://rubyforge.org/pipermail/eventmachine
-talk/2006-May/000060.html

I hope the following helps?

#### Start server code ####
#
#Start an instance of irb in a new shell
#
$stderr.sync = $stdout.sync = true
require 'rubygems'
require 'eventmachine'

 module EchoServer
   def receive_data data
     puts "Server received:  #"
     send_data ">>>you sent: #"
     puts "Server sent:  >>>you sent:
#"
     close_connection if data =~ /quit/i
   end
 end

 EventMachine::run {
   EventMachine::start_server "192.168.1.1", 8100,
EchoServer
 }

#### End server code ####

#### Start client code ####
#
#Start another instance of irb in a new shell
#
$stderr.sync = $stdout.sync = true
require 'rubygems'
require 'eventmachine'

 class EchoClient < EventMachine::Connection

   def receive_data data
     puts "Client Received: #"
     close_connection if data =~ /quit/i
   end
end
 cnt=0
 EventMachine::run {
   emc = EventMachine::connect "192.168.1.1",
8100, EchoClient
   EventMachine.add_periodic_timer(5) {cnt +=1;
emc.send_data "Message: #"}
 }

#### End client code ####



On 6/1/07, Eugueny Kontsevoy <....> wrote:
> Howdy,
>
> I googled your post:
> http://rubyforge.org/pipermail/eventmachine
-talk/2007-May/000695.html
>
> and I just ran into the same issue and must admit: I
stuck. What was it in
> your case, if you don't mind sharing?
> thank you.
>
>

On 5/8/07, Mark Van De Vyver <mvyvergmail.com> wrote:
> Hi,
> Please disregard the email below.
> I've worked out what my mistake was - all works as
expected!
> Apologies for the mail clutter
> Mark
>
>
>
> On 5/8/07, Mark Van De Vyver <mvyvergmail.com> wrote:
> > Hi,
> > I'm having some trouble running two EM examples.
> > I'm using the EM gem version 0.7.0
> > ruby --version:
> > ruby 1.8.5 (2006-08-25) [i586-linux]
> >
> > Operating system:
> > uname -a:
> > Linux mv-laptop 2.6.18.8-0.1-default #1 SMP Fri
Mar 2 13:51:59 UTC
> > 2007 i686 i686 i386 GNU/Linux
> >
> > the code example is below.  I have inserted my IP
address, as shown by
> > ifconfig -a.
> > If I use the code as below the ruby console is
empty.
> >
> > # ###### start code snippet ######
> >
> > require 'rubygems'
> > require 'eventmachine'
> >
> > module EchoServer
> >   def receive_data data
> >     send_data ">>>you sent:
#"
> >     close_connection if data =~ /quit/i
> >   end
> > end
> >
> > EventMachine::run {
> >   EventMachine::start_server
"192.168.1.1", 8100, EchoServer
> > }
> >
> > # ###### end code snippet ######
> >
> > If I use the port 8081 I get the following in the
ruby console:
> >
> >
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
> > `start_tcp_server': no acceptor (RuntimeError)
> >         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:445:in
> > `start_server'
> >         from lib/em_example.rb:12
> >         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
> > `call'
> >         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:791:in
> > `event_callback'
> >         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
> > `run_machine'
> >         from
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.7.0/lib/eventmach
ine.rb:201:in
> > `run'
> >         from lib/em_example.rb:11
> >
> > I have also tried to run the code example shown in
this post:
> > http://rubyforge.org/pipermail/eventmachine
-talk/2006-May/000060.html
> >
> > When I do, all I see in the console is (spaced 5
seconds apart):
> > []
> > []
> > []
> > .....
> >
> > I have tried the above two examples using
127.0.0.1 and a fully
> > qualified domain name - all give the same result.
> > Any suggestions about what I might have done or
configured incorrectly?
> >
> > Thanks in advance
> > Mark
> >
>
_______________________________________________
Eventmachine-talk mailing list
Eventmachine-talkrubyforge.org
http://rubyforge.org/mailman/listinfo/eventmachine-talk

Re: Two examples not running as expected
user name
2007-06-01 21:13:13
Sounds like you did figure it out Mark, but I wanted to point out one thing about the "no acceptor&quot; error. It's actually one of the more straightforward errors, and it essentially *always* means either that you used an IP address that isn't defined on that machine, or you aren't privileged enough to open the port, or it's already open in another process. There aren't any other realistic possibilities.
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )