I play with Remote Actors, but I have to face 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 wrote 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 ends!
It looks like a lot of threads were running in the client application, but they continue to work after the completion of my main function!
What can I do to complete the client application? And one more thing: what if I want my client to be able to start and stop connections? How can I achieve this?
Additional info (based on answers): I am using scala 2.8.0.final, and what I'm talking about is a standalone server and a standalone client. They should run as $ scala Server and $ scala Client . I want the Client application to end, but that will never happen.
Thanks!
source share