home *** CD-ROM | disk | FTP | other *** search
- // sockunix.h -*- C++ -*- socket library
- // Copyright (C) 1992,1993 Gnanasekaran Swaminathan <gs4t@virginia.edu>
- //
- // Permission is granted to use at your own risk and distribute this software
- // in source and binary forms provided the above copyright
- // notice and this paragraph are preserved on all copies.
- // This software is provided "as is" with no express or implied warranty.
- //
- // Version: 31Jan93 1.3
-
- #ifndef _SOCKUNIX_H
- #define _SOCKUNIX_H
-
- #include <sockstream.h>
- #include <sys/un.h>
-
- class sockunixaddr: public sockAddr, public sockaddr_un {
- public:
- sockunixaddr (const char* path="/tmp/unix_socket");
- operator void* () const { return (sockaddr_un*)this; }
-
- int size () const { return sizeof (sockaddr_un); }
- int family () const { return sun_family; }
- };
-
- class sockunixbuf: public sockbuf {
- protected:
- sockunixbuf& operator = (sockbuf& su);
- public:
- enum domain { af_unix = 1 };
-
- sockunixbuf (const sockbuf& su): sockbuf(su) {}
- sockunixbuf (sockbuf::type ty, int proto=0);
-
- sockbuf* open (sockbuf::type, int proto=0);
-
- virtual void bind (sockAddr& sa);
- void bind (const char* path);
- virtual void connect (sockAddr& sa);
- void connect (const char* path);
- };
-
- class isockunix: public isockstream
- {
- public:
- isockunix (const sockbuf& sb);
- isockunix (sockbuf::type ty=sockbuf::sock_stream,
- int proto=0);
- isockunix (sockunixbuf* sb, ostream* tied=0)
- : ios (sb, tied) { setf (ios::dont_close); }
-
- sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
- };
-
- class osockunix: public osockstream
- {
- public:
- osockunix (const sockbuf& sb);
- osockunix (sockbuf::type ty=sockbuf::sock_stream,
- int proto=0);
- osockunix (sockunixbuf* sb, ostream* tied=0)
- : ios (sb, tied) { setf (ios::dont_close); }
-
- sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
- };
-
- class iosockunix: public iosockstream
- {
- public:
- iosockunix (const sockbuf& sb);
- iosockunix (sockbuf::type ty=sockbuf::sock_stream,
- int proto=0);
- iosockunix (sockunixbuf* sb, ostream* tied=0)
- : ios (sb, tied) { setf (ios::dont_close); }
-
- sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
- };
-
- #endif _SOCKUNIX_H
-