Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package scalaz.example.nio
import scalaz._
import concurrent.Promise
import effects.IO
import nio.sockets._
import nio.Channels._
import Scalaz._
import iteratees._
import java.nio.channels.SocketChannel
import java.nio.channels.ByteChannel
import java.nio.ByteBuffer
object ExampleSocketServer {
def run(implicit s: concurrent.Strategy) {
val server = serverSocketChannel(8080)
val firstConnection : IO[Promise[SocketChannel]] = => FlattenI(s(head[Promise, SocketChannel]))).map(
val echo : IO[Iteratee[ByteBuffer, Promise, Unit]] = firstConnection flatMap { futureSocket =>
val consumer = writeToChannel[Promise]([ByteChannel]))
val reader = futureSocket map (i => readSocketChannel(i))
reader.get map (e => FlattenI(e(consumer)))
val runner : IO[Unit] =

This comment has been minimized.

Copy link
Owner Author

commented May 14, 2011

Simple echo server in my scalaz nio branch. Comments welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.