Description

Minimal range wrapper of socket

Package Information

Version1.0.1 (2016-Apr-18)
Repositoryhttps://github.com/ukatama/socketrange
LicenseMIT
CopyrightCopyright © 2015, ukatama
Authorsukatama
Registered byukatama
Dependenciesnone

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

socketrange Build Status

Simple range wrapper of socket for D.

Usage

import std.algorithm : equal;
import std.socket : socketPair;
import socketrange;

void main() {
  auto pair = socketPair();
  
  /// Wrap as OutputRange
  auto writer = SocketOutputRange!char(pair[0]);
  
  /// Wrap as InputRange of char
  auto reader = SocketInputRange!char(pair[1]);
  
  write.put("foobar");
  writer.close();
  
  assert(equal(reader, "foobar"));
}

struct SocketOutputRange(E)

Wrap socket as OutputRange of E. E can be void to put any types.

struct SocketInputRange(T)

Wrap socket as InputRange of T.

struct SocketRange(In, Out = In)

Wrap socket as Output/InputRange of In. Out can be void to put any types.

Available versions

1.0.1 1.0.0 0.2.0 0.1.1 0.1.0 ~master