Skip to content

lock-free/saio

Repository files navigation

saio

AIO library for scala

Quick example

import io.github.free.lock.saio.{ AIO, ConnectionHandler, AIOConnection }
import java.net.InetSocketAddress
import scala.concurrent.ExecutionContext.Implicits.global

val server = AIO.getTcpServer(
  onConnection = (connection: AIOConnection.Connection) => {
    ConnectionHandler(
      connection,
      onData = (data: Array[Byte]) => {
        val text = new String(data, "UTF-8")
        println(s"recieved data: ${text}") 
      }
    )
  }
)

val port = server.getLocalAddress().asInstanceOf[InetSocketAddress].getPort()

AIO.getTcpClient(port = port) map {
  conn =>
    val connHandler = ConnectionHandler(conn)
    connHandler.sendMessage("hello world!")
}

About

AIO library for scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published