Created
February 3, 2015 15:11
-
-
Save cqfd/b95a306bc54f72699c6e to your computer and use it in GitHub Desktop.
scalaz-stream echo server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.InetSocketAddress | |
import scala.concurrent.Task | |
import scalaz.stream._ | |
object Main { | |
def main(args: Array[String]): Unit = { | |
val address = new InetSocketAddress(45678) | |
implicit val cg = nio.DefaultAsynchronousChannelGroup | |
val s: Process[Task, Process[Task, Unit]] = nio.server(address).map { client => | |
client.flatMap { ex => | |
ex.read.to(ex.write).onFailure { e => Process.empty } | |
} | |
} | |
merge.mergeN(s).run.run | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment