vecio

vectored io for nim

Readme

vecio.nim

Build Status
vectored io for nim.

usage

just call readv or writev on a seq or array of strings, ptr strings, or seqs of uint8.

import net
import src/vecio

var server = newSocket()
server.setSockOpt(OptReuseAddr, true)
server.bindAddr(Port(3444))
server.listen()

block:
  let
    outgoing = newSocket()
    buf = ["foo", "bar"]
  outgoing.connect("localhost", Port(3444))
  discard outgoing.writev(buf)

var
  incomming = new Socket
  one = newString(2)
  two = newString(4)

# prevent the strings from being copied
one.shallow()
two.shallow()

var buf = [one, two]

server.accept(incomming)
discard incomming.readv(buf)
doAssert(buf == ["fo", "obar"])
server.close()
Need help? Read Nimble
Author:
emekoi
No tagged versions available
License: MIT

Project website Docs Hosted docs