home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 400_01 / socketpp-1.5 / test / tsinwrite.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  1.5 KB  |  54 lines

  1. // tsinwrite.cc. Test for -*- C++ -*- socket library
  2. // Copyright (C) 1992,1993 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: 07Nov93 1.5
  10.  
  11. #include <sockinet.h>
  12.  
  13. extern "C" {
  14.     int    atoi(const char*);
  15.     void    perror(const char*);
  16.     int    read(int fd, void* buf, int len);
  17. }
  18.  
  19.  
  20. main(int ac, char** av)
  21. {
  22.     if (ac < 3) {
  23.     cerr << "USAGE: " << av[0] << " machinename port "
  24.          << "format-string data...\n";
  25.     return 1;
  26.     }
  27.     
  28.     iosockinet    sio (sockbuf::sock_stream);
  29.     sockinetaddr    sin (av[1], atoi(av[2]));
  30.     
  31.     sio->connect(sin);
  32.     //  sio->shutdown(sockbuf::shut_read);
  33.     
  34.     //     cout << "local port = " << sio->localport() << endl
  35.     //          << " peer port = " << sio->peerport() << endl
  36.     //          << "local host = " << sio->localhost() << endl
  37.     //          << " peer host = " << sio->peerhost() << endl;
  38.     
  39.     av += 3;
  40.     while (*av) sio << *av++ << ' '; // space is neccessary
  41.     sio << endl; // endl to flush output
  42.     
  43.     char buf[256];
  44.     while (sio >> buf) cout << buf << ' ';
  45.     
  46.     cout << endl;
  47.     
  48.     
  49.     //     sio << "%f%d%c " // space is necessary
  50.     //         << 236.9 << ' '
  51.     //         << 56 << ' '
  52.     //         << 'c' << endl; // endl to flush output
  53. }
  54.