Main Page Class Hierarchy Compound List File List Compound Members Related Pages

# state_net.h

    00001
    00002 #ifndef _libqc_state_net_h
    00003 #define _libqc_state_net_h
    00004
    00005 /* state_net.h -- declarations for the socket StateOut classes
    00006  *
    00007  *      THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
    00008  *      "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
    00009  *      AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
    00010  *      CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
    00011  *      PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
    00012  *      RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
    00013  *
    00014  *  Author:
    00015  *      E. T. Seidl
    00016  *      Bldg. 12A, Rm. 2033
    00017  *      Computer Systems Laboratory
    00018  *      Division of Computer Research and Technology
    00019  *      National Institutes of Health
    00020  *      Bethesda, Maryland 20892
    00021  *      Internet: seidl@alw.nih.gov
    00022  *      October, 1992
    00023  */
    00024
    00025 #ifdef __GNUC__
    00026 #pragma interface
    00027 #endif
    00028
    00029
    00030 #include <util/state/state.h>
    00031
    00032 /*
    00033  * include <unistd.h>     for close()
    00034  * include <sys/types.h>   just in case rpc does not include this
    00035  * include <netinet/in.h>  for struct sockaddr and other IP things
    00036  * include <sys/un.h>      for struct sockaddr_un
    00037  */
    00038
    00039 #include <unistd.h>
    00040 #include <sys/types.h>
    00041 #include <netinet/in.h>
    00042 #if !defined(I860)
    00043 #include <sys/un.h>
    00044 #endif
    00045
    00046 /*
    00047  * include <malloc.h> because the ATT headers on the sun are brain dead
    00048  */
    00049 #if !defined(__GNUC__) && defined(SUN)
    00050 #include <malloc.h>
    00051 #endif
    00052
    00053 namespace sc {
    00054
    00055 // ////////////////////////////////////////////////////////////
    00056
    00057 class Socket {
    00058   protected:
    00059     int fd_;
    00060     Socket();
    00061   public:
    00062     virtual ~Socket();
    00063     virtual int close_socket();
    00064     inline const int fd() const { return fd_; }
    00065   };
    00066
    00067 // ////////////////////////////////////////////////////////////
    00068
    00069 class StreamSocket : virtual public Socket {
    00070   protected:
    00071     int writen(void*,int);
    00072     int readn(void*,int);
    00073     StreamSocket();
    00074   public:
    00075     ~StreamSocket();
    00076   };
    00077
    00078 class DGramSocket : virtual public Socket {
    00079   protected:
    00080     int sendn(void*,int,struct sockaddr*,int);
    00081     int recvn(void*,int,struct sockaddr*,int&);
    00082     DGramSocket();
    00083   public:
    00084     ~DGramSocket();
    00085   };
    00086
    00087 // ////////////////////////////////////////////////////////////
    00088
    00089 class BSDSocket : virtual public Socket {
    00090   protected:
    00091     struct sockaddr_in laddr_;
    00092     struct sockaddr_in raddr_;
    00093     int raddrlen;
    00094     BSDSocket();
    00095   public:
    00096     ~BSDSocket();
    00097     virtual int bind_socket(int);
    00098     virtual int connect_socket(const char*,int);
    00099   };
    00100
    00101 class BSD_TCPSocket: public BSDSocket, public StreamSocket {
    00102   protected:
    00103     BSD_TCPSocket();
    00104   public:
    00105     ~BSD_TCPSocket();
    00106
    00107     int bind_socket(int);
    00108     int listen_socket();
    00109     int listen_socket(BSD_TCPSocket&);
    00110   };
    00111
    00112 class BSD_UDPSocket: public BSDSocket, public DGramSocket {
    00113   protected:
    00114     BSD_UDPSocket();
    00115   public:
    00116     ~BSD_UDPSocket();
    00117   };
    00118
    00119 // ////////////////////////////////////////////////////////////
    00120
    00121 class StateOutBSD_TCP : virtual public BSD_TCPSocket, public StateOutXDR {
    00122   protected:
    00123     int put_array_void(const void*,int);
    00124   public:
    00125     StateOutBSD_TCP();
    00126     ~StateOutBSD_TCP();
    00127   };
    00128
    00129 class StateInBSD_TCP : virtual public BSD_TCPSocket, public StateInXDR {
    00130   protected:
    00131     int get_array_void(void*,int);
    00132   public:
    00133     StateInBSD_TCP();
    00134     ~StateInBSD_TCP();
    00135   };
    00136
    00137 class StateIOBSD_TCP : public StateInBSD_TCP, public StateOutBSD_TCP {
    00138   public:
    00139     StateIOBSD_TCP();
    00140     ~StateIOBSD_TCP();
    00141   };
    00142
    00143 // ////////////////////////////////////////////////////////////
    00144
    00145 class StateOutBSD_UDP : virtual public BSD_UDPSocket, public StateOutXDR {
    00146   protected:
    00147     int put_array_void(const void*,int);
    00148   public:
    00149     StateOutBSD_UDP();
    00150     ~StateOutBSD_UDP();
    00151   };
    00152
    00153 class StateInBSD_UDP : virtual public BSD_UDPSocket, public StateInXDR {
    00154   protected:
    00155     int get_array_void(void*,int);
    00156   public:
    00157     StateInBSD_UDP();
    00158     ~StateInBSD_UDP();
    00159   };
    00160
    00161 class StateIOBSD_UDP : public StateInBSD_UDP, public StateOutBSD_UDP {
    00162   public:
    00163     StateIOBSD_UDP();
    00164     ~StateIOBSD_UDP();
    00165   };
    00166
    00167 // ////////////////////////////////////////////////////////////
    00168
    00169 class UnixSocket : virtual public Socket {
    00170   protected:
    00171     struct sockaddr_un laddr_;
    00172     struct sockaddr_un raddr_;
    00173     int raddrlen;
    00174     UnixSocket();
    00175   public:
    00176     virtual ~UnixSocket();
    00177     int unlink_socket();
    00178     virtual int bind_socket(const char*);
    00179     virtual int connect_socket(const char*);
    00180   };
    00181
    00182 class UnixStreamSocket: public UnixSocket, public StreamSocket {
    00183   protected:
    00184     UnixStreamSocket();
    00185   public:
    00186     ~UnixStreamSocket();
    00187
    00188     int bind_socket(const char*);
    00189     int listen_socket();
    00190     int listen_socket(UnixStreamSocket&);
    00191   };
    00192
    00193 class UnixDGramSocket: public UnixSocket, public DGramSocket {
    00194   protected:
    00195     UnixDGramSocket();
    00196   public:
    00197     ~UnixDGramSocket();
    00198   };
    00199
    00200 // ////////////////////////////////////////////////////////////
    00201
    00202 class StateOutUnixStream : virtual public UnixStreamSocket, public StateOut {
    00203   protected:
    00204     int put_array_void(const void*,int);
    00205   public:
    00206     StateOutUnixStream();
    00207     ~StateOutUnixStream();
    00208   };
    00209
    00210 class StateInUnixStream : virtual public UnixStreamSocket, public StateIn {
    00211   protected:
    00212     int get_array_void(void*,int);
    00213   public:
    00214     StateInUnixStream();
    00215     ~StateInUnixStream();
    00216   };
    00217
    00218 class StateIOUnixStream: public StateInUnixStream, public StateOutUnixStream {
    00219   public:
    00220     StateIOUnixStream();
    00221     ~StateIOUnixStream();
    00222   };
    00223
    00224 // ////////////////////////////////////////////////////////////
    00225
    00226 class StateOutUnixDGram : virtual public UnixDGramSocket, public StateOut {
    00227   protected:
    00228     int put_array_void(const void*,int);
    00229   public:
    00230     StateOutUnixDGram();
    00231     ~StateOutUnixDGram();
    00232   };
    00233
    00234 class StateInUnixDGram : virtual public UnixDGramSocket, public StateIn {
    00235   protected:
    00236     int get_array_void(void*,int);
    00237   public:
    00238     StateInUnixDGram();
    00239     ~StateInUnixDGram();
    00240   };
    00241
    00242 class StateIOUnixDGram : public StateInUnixDGram, public StateOutUnixDGram {
    00243   public:
    00244     StateIOUnixDGram();
    00245     ~StateIOUnixDGram();
    00246   };
    00247
    00248 }
    00249
    00250 #endif
    00251
    00252 // Local Variables:
    00253 // mode: c++
    00254 // c-file-style: "ETS"
    00255 // End: