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 / sockunix.h < prev   
Encoding:
C/C++ Source or Header  |  1993-11-06  |  2.2 KB  |  80 lines

  1. // sockunix.h -*- 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: 31Jan93 1.3
  10.  
  11. #ifndef _SOCKUNIX_H
  12. #define    _SOCKUNIX_H
  13.  
  14. #include <sockstream.h>
  15. #include <sys/un.h>
  16.  
  17. class sockunixaddr: public sockAddr, public sockaddr_un {
  18. public:
  19.                 sockunixaddr (const char* path="/tmp/unix_socket");
  20.                 operator void* () const { return (sockaddr_un*)this; }
  21.  
  22.     int         size () const { return sizeof (sockaddr_un); }
  23.     int         family () const { return sun_family; }
  24. };
  25.  
  26. class sockunixbuf: public sockbuf {
  27. protected:
  28.     sockunixbuf&    operator = (sockbuf& su);
  29. public:
  30.     enum domain { af_unix = 1 };
  31.     
  32.                 sockunixbuf (const sockbuf& su): sockbuf(su) {}
  33.                 sockunixbuf (sockbuf::type ty, int proto=0);
  34.  
  35.     sockbuf*        open (sockbuf::type, int proto=0);
  36.  
  37.     virtual void    bind (sockAddr& sa);
  38.     void        bind (const char* path);
  39.     virtual void    connect (sockAddr& sa);
  40.     void        connect (const char* path);
  41. };
  42.  
  43. class isockunix: public isockstream
  44. {
  45. public:
  46.                 isockunix (const sockbuf& sb);
  47.                 isockunix (sockbuf::type ty=sockbuf::sock_stream,
  48.                           int proto=0);
  49.                 isockunix (sockunixbuf* sb, ostream* tied=0)
  50.                 : ios (sb, tied) { setf (ios::dont_close); }
  51.  
  52.     sockunixbuf*    operator -> () { return (sockunixbuf*)rdbuf (); }
  53. };
  54.  
  55. class osockunix: public osockstream
  56. {
  57. public:
  58.                 osockunix (const sockbuf& sb);
  59.                 osockunix (sockbuf::type ty=sockbuf::sock_stream,
  60.                    int proto=0);
  61.                 osockunix (sockunixbuf* sb, ostream* tied=0)
  62.                 : ios (sb, tied) { setf (ios::dont_close); }
  63.  
  64.     sockunixbuf*    operator -> () { return (sockunixbuf*)rdbuf (); }
  65. };
  66.  
  67. class iosockunix: public iosockstream
  68. {
  69. public:
  70.                 iosockunix (const sockbuf& sb);
  71.                 iosockunix (sockbuf::type ty=sockbuf::sock_stream,
  72.                     int proto=0);
  73.                 iosockunix (sockunixbuf* sb, ostream* tied=0)
  74.                 : ios (sb, tied) { setf (ios::dont_close); }
  75.  
  76.     sockunixbuf*    operator -> () { return (sockunixbuf*)rdbuf (); }
  77. };
  78.  
  79. #endif    _SOCKUNIX_H
  80.