ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/socket++-1.10/test/tsockpair.C
Revision: 1.1
Committed: Mon Feb 26 15:02:39 2001 UTC (24 years, 10 months ago) by ab11
Content type: text/plain
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Log Message:
Test programs for Networking class. Unused by the host

File Contents

# Content
1 // tsockpair.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
13 int main(int ac, char** av)
14 {
15 iopipestream p(sockbuf::sock_dgram);
16
17 if (p.fork()) {
18 // I am the Parent
19 p << ac << endl;
20 while (*av) {
21 p << *av++ << ' ';
22 }
23 p << endl;
24
25 char buf[128];
26 p.getline(buf,127);
27 cout << "Parent: " << buf << endl;
28 } else {
29 // I am the Child
30 int cnt=0;
31 int i;
32 char buf[32];
33
34 p >> i;
35 cout << "Child: " << i << ": ";
36 while (i--){
37 p >> buf;
38 cout << buf << ' ';
39 cnt++;
40 }
41 cout << endl;
42
43 p << "Child received " << cnt << " strings\n" << flush;
44 }
45 return 0;
46 }