ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/socket++-1.10/sockunix.h
Revision: 1.1
Committed: Mon Feb 26 15:01:39 2001 UTC (23 years, 9 months ago) by ab11
Content type: text/plain
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Log Message:
Networking class. Assumed to be bug free.

File Contents

# Content
1 // sockunix.h -*- 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 #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 sockunixaddr (const sockunixaddr& suna);
21 operator void* () const { return (sockaddr_un*)this; }
22
23 int size () const { return sizeof (sockaddr_un); }
24 int family () const { return sun_family; }
25 sockaddr* addr() const {return (sockaddr*)((sockaddr_un*)this);}
26 };
27
28 class sockunixbuf: public sockbuf {
29 protected:
30 sockunixbuf& operator = (const sockbuf& su);
31 sockunixbuf& operator = (const sockunixbuf& su);
32 public:
33 enum domain { af_unix = AF_UNIX };
34
35 sockunixbuf (const sockbuf& su): sockbuf(su) {}
36 sockunixbuf (const sockunixbuf& su): sockbuf (su) {}
37 sockunixbuf (sockbuf::type ty, int proto=0);
38
39 sockbuf* open (sockbuf::type, int proto=0);
40
41 virtual int bind (sockAddr& sa);
42 int bind (const char* path);
43 virtual int connect (sockAddr& sa);
44 int connect (const char* path);
45 };
46
47 class isockunix: public isockstream
48 {
49 public:
50 isockunix (const sockbuf& sb);
51 isockunix (sockbuf::type ty=sockbuf::sock_stream,
52 int proto=0);
53 ~isockunix();
54
55 sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
56 };
57
58 class osockunix: public osockstream
59 {
60 public:
61 osockunix (const sockbuf& sb);
62 osockunix (sockbuf::type ty=sockbuf::sock_stream,
63 int proto=0);
64 ~osockunix ();
65
66 sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
67 };
68
69 class iosockunix: public iosockstream
70 {
71 public:
72 iosockunix (const sockbuf& sb);
73 iosockunix (sockbuf::type ty=sockbuf::sock_stream,
74 int proto=0);
75 ~iosockunix ();
76
77 sockunixbuf* operator -> () { return (sockunixbuf*)rdbuf (); }
78 };
79
80 #endif // _SOCKUNIX_H