File: wvloopback.cc

package info (click to toggle)
wvstreams 4.6.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,820 kB
  • ctags: 7,837
  • sloc: cpp: 64,203; ansic: 4,154; sh: 4,094; makefile: 549; perl: 402
file content (39 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
 * 
 * Implementation of the WvLoopback stream.  WvLoopback uses a
 * socketpair() to create a stream that allows you to read()
 * everything written to it, even (especially) across a fork() call.
 */
#include "wvloopback.h"
#include "wvsocketpair.h"
#include "wvmoniker.h"
#include "wvlinkerhack.h"

WV_LINK(WvLoopback);

static IWvStream *create_loopback(WvStringParm, IObject *)
{
    return new WvLoopback();
}

static WvMoniker<IWvStream> reg("loop",  create_loopback);


WvLoopback::WvLoopback()
{
    int socks[2];
    
    if (wvsocketpair(SOCK_STREAM, socks))
    {
	seterr(errno);
	return;
    }
    
    rfd = socks[0];
    wfd = socks[1];

    set_close_on_exec(true);
    set_nonblock(true);
}