Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvloopback.cc

Go to the documentation of this file.
00001 /* 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Implementation of the WvLoopback stream. WvLoopback uses a 00006 * socketpair() to create a stream that allows you to read() 00007 * everything written to it, even (especially) across a fork() call. 00008 */ 00009 #include "wvloopback.h" 00010 00011 #ifndef _WIN32 00012 #include <sys/socket.h> 00013 #else 00014 #include <io.h> 00015 #endif 00016 #include <fcntl.h> 00017 00018 #ifdef _WIN32 00019 int socketpair (int family, int type, int protocol, int *sb); 00020 #endif 00021 00022 WvLoopback::WvLoopback() 00023 { 00024 int socks[2]; 00025 00026 if (socketpair(AF_UNIX, SOCK_STREAM, 0, socks)) 00027 { 00028 errnum = errno; 00029 return; 00030 } 00031 00032 rfd = socks[0]; 00033 wfd = socks[1]; 00034 00035 #ifndef _WIN32 00036 fcntl(rfd, F_SETFD, 1); 00037 fcntl(rfd, F_SETFL, O_RDONLY|O_NONBLOCK); 00038 fcntl(wfd, F_SETFD, 1); 00039 fcntl(wfd, F_SETFL, O_WRONLY|O_NONBLOCK); 00040 #else 00041 u_long arg = 1; 00042 ioctlsocket(rfd, FIONBIO, &arg); // non-blocking 00043 ioctlsocket(wfd, FIONBIO, &arg); // non-blocking 00044 #endif 00045 }

Generated on Tue Oct 5 01:09:20 2004 for WvStreams by doxygen 1.3.7