- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
[scala-language] Remote Actor not closing ports
Fri, 2011-01-28, 18:42
Hello, I am new to scala and was experimenting with RemoteActors and
found a strange issues.
pasting the code below into two scala consoles, the expectation would
be that the port would get closed (eventually) after the actor exits,
but that was not the case. The actor is in the terminated state. If i
try to instantiate another instance of it and start it again, remote
clients no longer send messages, no errors show up on either client or
server consoles. even if i call select a second time on client.
Is there a way to better control remote actors, and force them to
close all sockets and stop threads? Or am i just doing something
wrong?
Thanks,
Mark
Server Console:
import scala.actors._
import scala.actors.remote._
import scala.actors.Actor._
import scala.actors.remote.RemoteActor._
class RActor extends DaemonActor {
def act() {
alive(2401);
register('RActor, self)
loop {
react {
case msg=>{println(msg);exit()}
}
}
}
}
val ra = new RActor()
ra.start
and on client console:
import scala.actors._
import scala.actors.remote._
import scala.actors.Actor._
import scala.actors.remote.RemoteActor._
val ra = select(new Node("localhost",2401),'RActor)
ra ! "Hello"