Skip to content

esnya/socketrange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Simple range wrapper of socket for D

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages