| 1 |
// testall.cc. Test for -*- C++ -*- socket library |
| 2 |
// Copyright (C) 1992,1993,1994 Gnanasekaran Swaminathan <gs4t@virginia.edu> |
| 3 |
// |
| 4 |
// Permission is granted to use at your own risk and distribute this software |
| 5 |
// in source and binary forms provided the above copyright |
| 6 |
// notice and this paragraph are preserved on all copies. |
| 7 |
// This software is provided "as is" with no express or implied warranty. |
| 8 |
// |
| 9 |
// Version: 17Oct95 1.10 |
| 10 |
|
| 11 |
#include <pipestream.h> |
| 12 |
#include <unistd.h> |
| 13 |
#include <stdio.h> |
| 14 |
|
| 15 |
int main(int ac, char** av) |
| 16 |
{ |
| 17 |
char buf[256]; |
| 18 |
int portno; |
| 19 |
char thostname[64]; |
| 20 |
|
| 21 |
ipipestream tdunread("./tdunread /tmp/soc"); |
| 22 |
tdunread.getline(buf, 255); |
| 23 |
cout << buf << endl; |
| 24 |
ipipestream tdunwrite("./tdunwrite /tmp/soc mary had a little lamb"); |
| 25 |
while ( tdunread.getline(buf, 255) ) cout << buf << endl; |
| 26 |
cout << endl; |
| 27 |
|
| 28 |
ipipestream tdinread("./tdinread"); |
| 29 |
tdinread >> buf >> buf >> thostname >> buf >> buf >> portno; |
| 30 |
tdinread.getline(buf, 255); |
| 31 |
sprintf(buf, "./tdinwrite %s %d mary had a little lamb", |
| 32 |
thostname, portno); |
| 33 |
ipipestream tdinwrite(buf); |
| 34 |
while ( tdinread.getline(buf, 255) ) cout << buf << endl; |
| 35 |
tdinwrite.getline(buf, 255); |
| 36 |
tdinwrite.getline(buf, 255); |
| 37 |
while ( tdinwrite.getline(buf, 255) ) cout << buf << endl; |
| 38 |
cout << endl; |
| 39 |
|
| 40 |
ipipestream tsunread("./tsunread /tmp/soc"); |
| 41 |
tsunread.getline(buf, 255); |
| 42 |
cout << buf << endl; |
| 43 |
ipipestream tsunwrite("./tsunwrite /tmp/soc mary had a little lamb"); |
| 44 |
while ( tsunread.getline(buf, 255) ) cout << buf << endl; |
| 45 |
cout << endl; |
| 46 |
|
| 47 |
ipipestream tsinread("./tsinread"); |
| 48 |
tsinread >> buf >> buf >> thostname >> buf >> buf >> portno; |
| 49 |
tsinread.getline(buf, 255); |
| 50 |
sprintf(buf, "./tsinwrite %s %d %%d%%s%%f 356 haha 23.5", |
| 51 |
thostname, portno); |
| 52 |
ipipestream tsinwrite1(buf); |
| 53 |
sprintf(buf, "./tsinwrite %s %d %%s%%c oooiiii !", |
| 54 |
thostname, portno); |
| 55 |
cout << "sleeping for 3 sec\n"; |
| 56 |
sleep(3); |
| 57 |
ipipestream tsinwrite2(buf); |
| 58 |
while ( tsinread.getline(buf, 255) ) cout << "tsinread: " << buf << endl; |
| 59 |
while ( tsinwrite1.getline(buf, 255) ) |
| 60 |
cout << "tsinwrite1: " << buf << endl; |
| 61 |
while ( tsinwrite2.getline(buf, 255) ) |
| 62 |
cout << "tsinwrite2: " << buf << endl; |
| 63 |
cout << endl; |
| 64 |
|
| 65 |
ipipestream tpipe("./tpipe mary had a little lamb"); |
| 66 |
while ( tpipe.getline(buf, 255) ) cout << "tpipe " << buf << endl; |
| 67 |
cout << endl; |
| 68 |
|
| 69 |
ipipestream tsockpair("./tsockpair mary had a little lamb"); |
| 70 |
while ( tsockpair.getline(buf, 255) ) |
| 71 |
cout << "tsockpair " << buf << endl; |
| 72 |
cout << endl; |
| 73 |
|
| 74 |
ipipestream tpopen ("./tpopen"); |
| 75 |
while ( tpopen.getline(buf, 255) ) |
| 76 |
cout << "tpopen " << buf << endl; |
| 77 |
cout << endl; |
| 78 |
|
| 79 |
ipipestream twhois("./twhois .knuth,donald"); |
| 80 |
cout <<"twhois:\n"; |
| 81 |
while ( twhois.getline(buf, 255) ) cout << buf << endl; |
| 82 |
cout << endl; |
| 83 |
|
| 84 |
ipipestream thost("./thostnames uvaarpa.virginia.edu"); |
| 85 |
cout << "thostnames:\n"; |
| 86 |
while ( thost.getline(buf, 255) ) cout << buf << endl; |
| 87 |
cout << endl; |
| 88 |
|
| 89 |
return 0; |
| 90 |
} |
| 91 |
|