ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/socket++-1.10/test/tsunread.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 // tsunread.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 <sockunix.h>
12 #include <unistd.h>
13 #include <errno.h>
14
15 #if defined (__alpha) && defined (__DECCXX)
16 extern "C" int chmod (const char*, int);
17 #endif
18
19 int main(int ac, char** av)
20 {
21 if (ac != 2) {
22 cerr << "USAGE: " << av[0] << " socket_path_name\n";
23 return 1;
24 }
25
26 sockunixbuf su (sockbuf::sock_stream);
27
28 su.bind (av[1]);
29 cout << "Socket name = " << av[1] << endl;
30
31 if (chmod(av[1], 0777) == -1) {
32 perror("chmod");
33 return 1;
34 }
35
36 su.listen (3);
37 iosockunix iosun (su.accept());
38
39 char buf[1024];
40
41 iosun << av[0] << ' ' << av[1] << endl;
42
43 while ( iosun >> buf ) cout << av[0] << ": " << buf << endl;
44
45 unlink (av[1]);
46 return 0;
47 }
48