This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[scala-language] Remote Actor not closing ports

No replies
Mark
Joined: 2011-01-28,
User offline. Last seen 42 years 45 weeks ago.

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"

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland