1 |
ab11 |
1.1 |
// tdunread.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 <stdio.h> // solaris2.3 perror is here |
14 |
|
|
#include <sys/stat.h> // solaris 2.3 chmod is here |
15 |
|
|
#include <errno.h> |
16 |
|
|
|
17 |
|
|
int main(int ac, char** av) |
18 |
|
|
{ |
19 |
|
|
if (ac != 2) { |
20 |
|
|
cerr << "USAGE: " << av[0] << " socket_path_name\n"; |
21 |
|
|
return 1; |
22 |
|
|
} |
23 |
|
|
|
24 |
|
|
isockunix su (sockbuf::sock_dgram); |
25 |
|
|
|
26 |
|
|
su->bind(av[1]); |
27 |
|
|
|
28 |
|
|
cout << "Socket name = " << av[1] << endl; |
29 |
|
|
|
30 |
|
|
if (chmod (av[1], 0777) == -1) { |
31 |
|
|
perror("chmod"); |
32 |
|
|
return 1; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
char buf[1024]; |
36 |
|
|
int i; |
37 |
|
|
su >> i; |
38 |
|
|
cout << av[0] << ": " << i << " strings: "; |
39 |
|
|
while (i--) { |
40 |
|
|
su >> buf; |
41 |
|
|
cout << buf << ' '; |
42 |
|
|
} |
43 |
|
|
cout << endl; |
44 |
|
|
unlink(av[1]); |
45 |
|
|
|
46 |
|
|
return 0; |
47 |
|
|
} |