WvStreams
|
00001 /* 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Implementation of a two-way version of WvLoopback. See wvloopback2.h. 00006 */ 00007 #include "wvloopback2.h" 00008 #include "wvsocketpair.h" 00009 00010 void wvloopback2(IWvStream *&s1, IWvStream *&s2) 00011 { 00012 int socks[2]; 00013 00014 if (wvsocketpair(SOCK_STREAM, socks)) 00015 { 00016 int errnum = errno; 00017 s1 = new WvStream; 00018 s2 = new WvStream; 00019 s1->seterr(errnum); 00020 s2->seterr(errnum); 00021 return; 00022 } 00023 00024 WvFdStream *f1 = new WvFdStream(socks[0], socks[0]); 00025 WvFdStream *f2 = new WvFdStream(socks[1], socks[1]); 00026 00027 f1->set_close_on_exec(true); 00028 f2->set_close_on_exec(true); 00029 f1->set_nonblock(true); 00030 f2->set_nonblock(true); 00031 00032 s1 = f1; 00033 s2 = f2; 00034 }