How to terminate Scala Remote Actor client? -


I am playing with remote actors, but I have to face some difficulties.

Consider this server: server server {ARRE [string]) {val server = new server server.start}} extends class server actor {RemoteActor.alive (12345) RemoteActor.register ( 'Server, this def def () {while {true} {receives {case x = & gt; I have written a simple customer:

  object client {df main (args: array [string]) {print} {} Val Server = RemoteActor.select (node ​​("localhost", 12345), server 'server! "Hey!" }}  

As expected, the server "Hey!" Prints.

However, unexpectedly, the client application never ends!

It seems as though many threads have been started on the client application, but they keep running after the main function is over!

What can I do to end the client application? And more: What if I want my client to start and stop the connection? How can I get this?

Some additional information (depending on the answer): I am using Scala 2.8.0.final, and what I'm talking about here is a standalone server and a standalone client I should be launched as $ scala server and $ scala client . What I have to do, is that the application "client" should end, but it never happens.

Thank you!

Do not send messages to other artists outside of the actor while Scala gladly accepts it, such as You are watching. Here is an equivalent code that works:

  import scala.actors.remote._ object act scala.actors.Actor (ext) = {val server = RemoteActor.select (node ​​(" Localhost ", 12345), 'server' server! "Hey!" }} Object Client {Diff Main (Args: Array [String]) {Act.start ()}}  

Or, more bus,

  import Scala.actors.Actor.actor import scala.actors.remote._Object Client {Deaf Main (Args: Array [String]) {Actor {Val Server = Remoteactor. Selection (node ​​("localhost", 12345), server 'server! "Hey!" }}}  

Comments