title: Scala client server multithreaded using socket
body: <p>I cant get my head around this one here
  I am a beginner to Scala just few weeks old and have tried but failed 
  I have read and tried about Actors, Futures,...etc didnt work for me </p>
  
  <p>Could you supply a code of a server client example (or at least the server side)
  Suppose to open connection using a socket that receives a string (i.e. file path) from several clients and process each one in a thread </p>
  
  <pre><code>import java.net.{Socket, ServerSocket}
  import java.util.concurrent.{Executors, ExecutorService}
  import java.util.Date
  import java.io._
  import scala.io._
  import java.nio._
  import java.util._
  import scala.util.control.Breaks
  import java.security.MessageDigest
  import java.security.DigestInputStream
  import scala.util.Sorting
  
  class NetworkService(port: Int, poolSize: Int) extends Runnable {
    val serverSocket = new ServerSocket(port)
    val pool: ExecutorService = Executors.newFixedThreadPool(poolSize)
  
    def run() {
      try {
        var i = 0
        while (true) {
          // This will block until a connection comes in.
          val socket = serverSocket.accept()
          val in = new BufferedReader(new InputStreamReader(socket.getInputStream)).readLine
          /*var f = new FileSplit(in) //FileSplit is another class that i would like each                   
                                      // client's sent string to be passed as an instance of 
            f.move*/
          pool.execute(new Handler(socket))
  
        }
      } finally {
        pool.shutdown()
  
  
      }
    }
  
  }
  
  class Handler(socket: Socket) extends Runnable {
    def message = (Thread.currentThread.getName() + "\n").getBytes
  
    def run() {
      socket.getOutputStream.write(message)
      socket.getOutputStream.close()
  
    }
  }
  
  
  object MyServer {
    def main(args: Array[String]) {
  (new NetworkService(2030, 2)).run
  
  }
  }
  </code></pre>