Socket Programming

I’m trying to do Udp socket programming, but how can I get input from the user while writing the server side?

import{BufferedReader, InputStreamReader, PrintWriter}
import{DatagramPacket, DatagramSocket}

class UdpServer {

  var socket = null
  var running = false
  val buf = new Array[Byte](256)

  def start(port : Int, hostname : String) : Unit ={

    var socket_listening = new DatagramSocket(hostname,port)
    //var clientSockett = socket_listening.connect(port)
    var in = new BufferedReader(new InputStreamReader())

    var close : Boolean = false

    while(!close) {
      println("Waiting message..")
      val msg =


It is not clear what the question / problem is?

However, I would advise using something more high level like fs2 which may simplify the task at hand.