1 |
// tsinwrite.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 <sockinet.h> |
12 |
#include <stdlib.h> |
13 |
#include <unistd.h> |
14 |
#include <errno.h> |
15 |
|
16 |
int main(int ac, char** av) |
17 |
{ |
18 |
if (ac < 3) { |
19 |
cerr << "USAGE: " << av[0] << " machinename port " |
20 |
<< "format-string data...\n"; |
21 |
return 1; |
22 |
} |
23 |
|
24 |
iosockinet sio (sockbuf::sock_stream); |
25 |
sio->connect(av [1], atoi (av [2])); |
26 |
// sio->shutdown(sockbuf::shut_read); |
27 |
|
28 |
// cout << "local port = " << sio->localport() << endl |
29 |
// << " peer port = " << sio->peerport() << endl |
30 |
// << "local host = " << sio->localhost() << endl |
31 |
// << " peer host = " << sio->peerhost() << endl; |
32 |
|
33 |
av += 3; |
34 |
while (*av) sio << *av++ << ' '; // space is neccessary |
35 |
sio << endl; // endl to flush output |
36 |
|
37 |
char buf[256]; |
38 |
while (sio >> buf) cout << buf << ' '; |
39 |
cout << endl; |
40 |
|
41 |
|
42 |
// sio << "%f%d%c " // space is necessary |
43 |
// << 236.9 << ' ' |
44 |
// << 56 << ' ' |
45 |
// << 'c' << endl; // endl to flush output |
46 |
|
47 |
return 0; |
48 |
} |