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 / tdinwrite.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  2.0 KB  |  61 lines

  1. // tdinwrite.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.     int    getpid();
  16.     int    getpgrp();
  17. }
  18.  
  19. main(int ac, char** av)
  20. {
  21.     if (ac < 3) {
  22.         cerr << "USAGE: " << av[0] << " thostname port-number "
  23.              << "data ... " << endl;
  24.         return 1;
  25.     }
  26.  
  27.     osockinet osin (sockbuf::sock_dgram);
  28.  
  29.     osin->connect (av[1], atoi (av[2]));
  30.  
  31.     cout << "local: " << osin->localport() << ' ' << osin->localhost() << endl
  32.          << "peer:  " << osin->peerport() << ' ' << osin->peerhost() << endl;
  33.  
  34.     // test socket options
  35.     cout << "socket type = " << osin->gettype() << endl
  36.          << "socket linger time = " << osin->linger(10) << endl
  37.          << "socket linger time = " << osin->linger(0)  << endl
  38.          << "socket linger time = " << osin->linger()   << endl
  39. //          << "socket send bufsz = " << osin->sendbufsz() << endl
  40. //          << "socket recv bufsz = " << osin->recvbufsz() << endl
  41.          << "socket keepalive  = " << osin->keepalive(1) << endl
  42.          << "socket keepalive  = " << osin->keepalive(0) << endl
  43.          << "socket clearerror = " << osin->clearerror() << endl
  44.          << "socket debug = " << osin->debug(1) << endl
  45.          << "socket debug = " << osin->debug(0) << endl
  46.          << "socket reuse = " << osin->reuseaddr(1) << endl
  47.          << "socket reuse = " << osin->reuseaddr(0) << endl;
  48.     int timeo;
  49.     osin->getopt(sockbuf::so_sndtimeo, &timeo, sizeof(timeo));
  50.     cout << "socket sendtimeo = " << timeo << endl;
  51.     osin->getopt(sockbuf::so_rcvtimeo, &timeo, sizeof(timeo));
  52.     cout << "socket recvtimeo = " << timeo << endl;
  53.  
  54.     osin << ac-3; av += 3;
  55.     while(*av) osin << *av++ << ' ';
  56.     osin << endl;
  57. }
  58.  
  59.     
  60.     
  61.