File: udglistentest.cc

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (43 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (2)
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
40
41
42
43
/*
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2004 Net Integration Technologies, Inc.
 *
 * WvUnixDGListener test.  Creates a Unix Domain socket on /tmp/fuzzy or
 * whatever you give it on the command line, prints anything it receives to
 * stdout.
 */
#include "wvunixdgsocket.h"
#include "wvlog.h"
#include "wvistreamlist.h"

#define DEFAULT "/tmp/fuzzy"

int main(int argc, char **argv ) 
{
    WvLog log(("unixdatagramlisten"), WvLog::Debug1);

    WvString filename;
    if (argc == 2) 
        filename = argv[1];
    else 
        filename = DEFAULT;
        

    WvUnixDGListener sock(filename, 0777);

    sock.autoforward(*wvout);

    log("Listening on %s\n", filename);
   
    WvIStreamList l;
    l.add_after(l.tail, &sock, false);
    l.add_after(l.tail, wvcon, false);

    while (sock.isok() && wvout->isok()) 
    {
        if (l.select(-1))
            l.callback();
    }

    return 0;
}