Hi.
I'm playing with Remote Actors but I'm facing some difficulties.
Consider this server:
object Server {
def main(args: Array[String]) {
val server = new Server
server.start
}
}
class Server extends Actor {
RemoteActor.alive(12345)
RemoteActor.register('server, this)
def act() {
while(true) {
receive { case x => println(x) }
}
}
}
I have written a simple client:
object Client {
def main(args: Array[String]) {
val server = RemoteActor.select(Node("localhost", 12345), 'server)
server ! "Hey!"
}
}
As expected, the server prints "Hey!".
However, unexpectedly, the client application never terminates!
It looks like many thread have been started on the client application, but they keep running after my main function finishes!
What can I do to terminate the client application? And more: what if I want my client to be able to start and stop connections? How can I achieve this?
Some additional info (based on replies): I'm using scala 2.8.0.final, and what I'm talking about here is a standalone server and a standalone client. They should be launched like $ scala Server
and $ scala Client
. What I want to happen is that the application "Client" should finish, but it never happens.
Thanks!