Help with university assignment

So, we are supposed to create an xml-rpc based event manager using 2-3
programming languages. C#, Java, Ruby.

I opted for ruby(i did this course last year but the dropped out).
So, this time i am really trying.
The code is not the actual problem for me.

It is the testing.

Right now i am attempting this: my usual machine(windows 7), and a
virtual machine running windows xp.

in both there is the same program:

require “xmlrpc/server”
require “xmlrpc/client”
eventCounter=0
t1=Thread.new{
s = XMLRPC::Server.new(8080)

s.add_handler(“add”) do|id,date,time,duration,header,comment|
eventCounter=eventCounter+1
File.open("#{id}"+".event", ‘w’) {|f| f.write("#{date}| #{time}|
#{duration}| #{header}| #{comment}") }

end

s.add_handler(“delete”)do |id|
File.delete("#{id}"+".event")
end
s.set_default_handler do |name, *args|
raise XMLRPC::FaultException.new(-99, “Method #{name} missing” +
" or wrong number of parameters!")
end

s.serve
}
t2=Thread.new{
server = XMLRPC::Client.new(“127.0.0.1”, “/RPC2”, 8080)
begin
puts “Press 1 to add an event\n”
puts “Press 2 to remove an event of given ID\n”
whatToDo=gets.to_i

while whatToDo!="-1"
  puts "Press 1 to add an event\n"
  puts "Press 2 to remove an event of given ID\n"
  whatToDo=gets.to_i

  case whatToDo
    when 1

    server.call("add",eventCounter,"03/10/2011","sadkfdsa","not

long",“some header”,“some comment”)
when 2
puts “Input ID to delete\n”
id=gets.to_i

    server.call("delete",id)
    else
    puts "Please input 1 or 2"

  end
  #server.call("delete","2")   Delete example

end

end

}
t2.join

One one computer i am running port 8080, on the other 8090 for the
xmlrpc::server.new

I was also wondering, which ip do i have to write? i tried 127.0.0.1 but
that ofcourse executes locally.
I tried 192.168.0.7 and .8 depending on the machines(their
corresponding ip for the router).

I also tried my web ip, but ofc that is the same for both machines cos
i’m behind 1 router.

Can some1 please help me in this part? If i get past this, i can test my
code everytime i plan something. This ofcourse means i can do my
assignment.

Ofcourse i opened the ports 8080 and 8090 in my router.

I have also attempted running the example code for xmlrpc server and
client.
require “xmlrpc/server”

s = XMLRPC::Server.new(8080)

s.add_handler(“michael.add”) do |a,b|
a + b
end

s.add_handler(“michael.div”) do |a,b|
if b == 0
raise XMLRPC::FaultException.new(1, “division by zero”)
else
a / b
end
end

s.set_default_handler do |name, *args|
raise XMLRPC::FaultException.new(-99, “Method #{name} missing” +
" or wrong number of parameters!")
end

s.serve

require “xmlrpc/client”

server = XMLRPC::Client.new(“www.ruby-lang.org”, “/RPC2”, 8080)
begin
param = server.call(“michael.add”, 4, 5)
puts “4 + 5 = #{param}”
rescue XMLRPC::FaultException => e
puts “Error:”
puts e.faultCode
puts e.faultString
end

I really have no idea what i am doing wrong. And i do understand it isnt
really a ruby question, but i really have no idea where i could ask a
question like this

If somebody can solve this, then cyber beer is yours forever :slight_smile:

Regards, Nikita

On Tue, Oct 4, 2011 at 8:37 AM, Nikita Kuznetsov
[email protected] wrote:

assignment.
My Arch Linux VM:

08:42:[email protected]:/home/phgaw
$ hostname
lee
08:42:[email protected]:/home/phgaw
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:3B:93:1E
inet addr:192.168.133.128 Bcast:192.168.133.255
Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe3b:931e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46481 errors:0 dropped:0 overruns:0 frame:0
TX packets:32846 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37169553 (35.4 Mb) TX bytes:4967809 (4.7 Mb)
Interrupt:19 Base address:0x2024

Pinging lee from Grant:
PS C:> ping lee

Pinging lee [192.168.133.128] with 32 bytes of data:
Reply from 192.168.133.128: bytes=32 time<1ms TTL=64
Reply from 192.168.133.128: bytes=32 time<1ms TTL=64
Reply from 192.168.133.128: bytes=32 time<1ms TTL=64
Reply from 192.168.133.128: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.133.128:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

Networking mode is set to: NAT, with VMware Player taking care of DHCP
for the VMs.

The best place to ask is the fora for the virtualization solution you
are using.


Phillip G.

gplus.to/phgaw | twitter.com/phgaw

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibniz

What software are you using for your virtual machine? it sounds like a
network configuration issue. If you use VirtualBox, just configure a
bridged connection and forward the ports properly from your host
machine to your virtual machine.

  • Xavier

On Mon, Oct 3, 2011 at 11:47 PM, Phillip G.

i figured out the problem. I was doing server.new(8080) and i should
have been doing server.new(8080,“192.168.0.x”) after that, it was all
fine. It worked through a VM, through my WLAN at home, i will soon test
it over the net. But yea, thanks for the time spent anyway guys, i got
it all figured out now. Assignement is almost finished.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs