github.com/zachmokahn/SUV

It's libuv. In a box. With wheels.


License
MIT

Documentation

SUV

depends on libuv version 1.8.0-r1

libUV bindings for swift. This is still very much a Work-In-Progress, meaning and a lot might (and very likely will) change. Stay tuned.

Installation using Swift Package Manager

  • Make sure libuv is installed

    clone the repo and checkout to the v1.8.0 tag. install according to the documentation

  • Add this line to your Package.swift file.

    .Package(url: "https://github.com/zachmokahn/SUV.git", Version(0,0,1))

Use

Import SUV, write some code, and start the event loop.

    /* /project/path/Sources/EchoSerer/main.swift */

    import SUV

    let server = TCPHandle(Loop.defaultLoop)
    server.bind(Addr(AddrIn("0.0.0.0", 8000)))

    StreamHandle(server).listen { connection, status in
      let client = StreamHandle(TCPHandle(connection.loop))

      client.accept(connection)

      client.read { stream, result, buffer in
        WriteRequest().write(stream, buffer) { request, status in
          request.free()
          client.close { $0.free() }
        }
      }
    }

    Loop.defaultLoop.run(.Default)

More Examples Can be found at the SUVExamples repo