WvStreams
wvloopback.cc
1/*
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * Implementation of the WvLoopback stream. WvLoopback uses a
6 * socketpair() to create a stream that allows you to read()
7 * everything written to it, even (especially) across a fork() call.
8 */
9#include "wvloopback.h"
10#include "wvsocketpair.h"
11#include "wvmoniker.h"
12#include "wvlinkerhack.h"
13
14WV_LINK(WvLoopback);
15
16static IWvStream *create_loopback(WvStringParm, IObject *)
17{
18 return new WvLoopback();
19}
20
21static WvMoniker<IWvStream> reg("loop", create_loopback);
22
23
24WvLoopback::WvLoopback()
25{
26 int socks[2];
27
28 if (wvsocketpair(SOCK_STREAM, socks))
29 {
30 seterr(errno);
31 return;
32 }
33
34 rfd = socks[0];
35 wfd = socks[1];
36
38 set_nonblock(true);
39}
The basic interface which is included by all other XPLC interfaces and objects.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
void set_nonblock(bool nonblock)
Make the fds on this stream blocking or non-blocking.
Definition wvfdstream.cc:97
void set_close_on_exec(bool close_on_exec)
Make the fds on this stream close-on-exec or not.
Implementation of a WvLoopback stream.
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
virtual void seterr(int _errnum)
Override seterr() from WvError so that it auto-closes the stream.
Definition wvstream.cc:451