Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:28:14+00:00 2026-05-18T01:28:14+00:00

I am writing a simple chat server, and I want to keep it as

  • 0

I am writing a simple chat server, and I want to keep it as simple as possible. My server listed below only receives connections and stores them in the clients set. Incoming messages are then broadcasted to all clients on that Server. The server works with no problem, but on the client side, the RemoteActor stops my program from termination. Is there a way to remove the Actor on my client without terminating the Actor on the Server?

I don’t want to use a “one actor per client” model yet.

 import actors.{Actor,OutputChannel}
 import actors.remote.RemoteActor

 object Server extends Actor{
  val clients = new collection.mutable.HashSet[OutputChannel[Any]]
  def act{
   loop{
    react{
     case 'Connect =>
      clients += sender
     case 'Disconnect =>
      clients -= sender
     case message:String =>
      for(client <- clients)
      client ! message
    }
   }
  }

  def main(args:Array[String]){
   start
   RemoteActor.alive(9999)
   RemoteActor.register('server,this)
  }
 }

my client would then look like this

val server = RemoteActor.select(Node("localhost",9999),'server)
server.send('Connect,messageHandler) //answers will be redirected to the messageHandler
/*do something until quit*/
server ! 'Disconnect
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:28:14+00:00Added an answer on May 18, 2026 at 1:28 am

    I would suggest placing the client side code into an actor itself – ie not calling alive/register in the main thread

    (implied by http://www.scala-lang.org/api/current/scala/actors/remote/RemoteActor$.html)

    something like

    //body of your main: 
    val client = actor { 
       alive(..)
       register(...)
       loop { 
           receive {
               case 'QUIT => exit()
           }
        } 
    }
    client.start
    //then to quit:
    client ! 'QUIT
    

    Or similar (sorry I am not using 2.8 so might have messed something up – feel free to edit if you make it actually work for you !).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am writing a simple client/server chat program with indy 10 (blocking mode) and
I'm writing a simple OpenGL application that uses GLUT . I don't want to
I'm writing a simple CMS. I want to be able to load a View,
I'm writing a simple chat module that will be embedded in a website. It
I'm writing a TCP chat server ( programming language does not mather ). It's
I'm currently writing a simple cross platform app with Node.js on the server and
How long does it take for an experienced Windows programmer to learn writing simple
I'm writing a simple app that's going to have a tiny form sitting in
I am currently writing a simple, timer-based mini app in C# that performs an
I am writing a simple checkers game in Java. When I mouse over the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.