The OpenD Programming Language

socketPair

Creates a pair of connected sockets.

The two sockets are indistinguishable.

@safe @trusted
socketPair
()

Throws

SocketException if creation of the sockets fails.

Examples

immutable ubyte[4] data = [1, 2, 3, 4];
auto pair = socketPair();
scope(exit) foreach (s; pair) s.close();

pair[0].send(data[]);

auto buf = new ubyte[data.length];
pair[1].receive(buf);
assert(buf == data);

Meta