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 // ////////////////////////////////////////////////////////////
00054 
00055 class Socket {
00056   protected:
00057     int fd_;
00058     Socket();
00059   public:
00060     virtual ~Socket();
00061     virtual int close_socket();
00062     inline const int fd() const { return fd_; }
00063   };
00064 
00065 // ////////////////////////////////////////////////////////////
00066 
00067 class StreamSocket : virtual public Socket {
00068   protected:
00069     int writen(void*,int);
00070     int readn(void*,int);
00071     StreamSocket();
00072   public:
00073     ~StreamSocket();
00074   };
00075 
00076 class DGramSocket : virtual public Socket {
00077   protected:
00078     int sendn(void*,int,struct sockaddr*,int);
00079     int recvn(void*,int,struct sockaddr*,int&);
00080     DGramSocket();
00081   public:
00082     ~DGramSocket();
00083   };
00084 
00085 // ////////////////////////////////////////////////////////////
00086 
00087 class BSDSocket : virtual public Socket {
00088   protected:
00089     struct sockaddr_in laddr_;
00090     struct sockaddr_in raddr_;
00091     int raddrlen;
00092     BSDSocket();
00093   public:
00094     ~BSDSocket();
00095     virtual int bind_socket(int);
00096     virtual int connect_socket(const char*,int);
00097   };
00098 
00099 class BSD_TCPSocket: public BSDSocket, public StreamSocket {
00100   protected:
00101     BSD_TCPSocket();
00102   public:
00103     ~BSD_TCPSocket();
00104 
00105     int bind_socket(int);
00106     int listen_socket();
00107     int listen_socket(BSD_TCPSocket&);
00108   };
00109 
00110 class BSD_UDPSocket: public BSDSocket, public DGramSocket {
00111   protected:
00112     BSD_UDPSocket();
00113   public:
00114     ~BSD_UDPSocket();
00115   };
00116 
00117 // ////////////////////////////////////////////////////////////
00118 
00119 class StateOutBSD_TCP : virtual public BSD_TCPSocket, public StateOutXDR {
00120   protected:
00121     int put_array_void(const void*,int);
00122   public:
00123     StateOutBSD_TCP();
00124     ~StateOutBSD_TCP();
00125   };
00126 
00127 class StateInBSD_TCP : virtual public BSD_TCPSocket, public StateInXDR {
00128   protected:
00129     int get_array_void(void*,int);
00130   public:
00131     StateInBSD_TCP();
00132     ~StateInBSD_TCP();
00133   };
00134 
00135 class StateIOBSD_TCP : public StateInBSD_TCP, public StateOutBSD_TCP {
00136   public:
00137     StateIOBSD_TCP();
00138     ~StateIOBSD_TCP();
00139   };
00140 
00141 // ////////////////////////////////////////////////////////////
00142 
00143 class StateOutBSD_UDP : virtual public BSD_UDPSocket, public StateOutXDR {
00144   protected:
00145     int put_array_void(const void*,int);
00146   public:
00147     StateOutBSD_UDP();
00148     ~StateOutBSD_UDP();
00149   };
00150 
00151 class StateInBSD_UDP : virtual public BSD_UDPSocket, public StateInXDR {
00152   protected:
00153     int get_array_void(void*,int);
00154   public:
00155     StateInBSD_UDP();
00156     ~StateInBSD_UDP();
00157   };
00158 
00159 class StateIOBSD_UDP : public StateInBSD_UDP, public StateOutBSD_UDP {
00160   public:
00161     StateIOBSD_UDP();
00162     ~StateIOBSD_UDP();
00163   };
00164 
00165 // ////////////////////////////////////////////////////////////
00166 
00167 class UnixSocket : virtual public Socket {
00168   protected:
00169     struct sockaddr_un laddr_;
00170     struct sockaddr_un raddr_;
00171     int raddrlen;
00172     UnixSocket();
00173   public:
00174     virtual ~UnixSocket();
00175     int unlink_socket();
00176     virtual int bind_socket(const char*);
00177     virtual int connect_socket(const char*);
00178   };
00179 
00180 class UnixStreamSocket: public UnixSocket, public StreamSocket {
00181   protected:
00182     UnixStreamSocket();
00183   public:
00184     ~UnixStreamSocket();
00185 
00186     int bind_socket(const char*);
00187     int listen_socket();
00188     int listen_socket(UnixStreamSocket&);
00189   };
00190 
00191 class UnixDGramSocket: public UnixSocket, public DGramSocket {
00192   protected:
00193     UnixDGramSocket();
00194   public:
00195     ~UnixDGramSocket();
00196   };
00197 
00198 // ////////////////////////////////////////////////////////////
00199 
00200 class StateOutUnixStream : virtual public UnixStreamSocket, public StateOut {
00201   protected:
00202     int put_array_void(const void*,int);
00203   public:
00204     StateOutUnixStream();
00205     ~StateOutUnixStream();
00206   };
00207 
00208 class StateInUnixStream : virtual public UnixStreamSocket, public StateIn {
00209   protected:
00210     int get_array_void(void*,int);
00211   public:
00212     StateInUnixStream();
00213     ~StateInUnixStream();
00214   };
00215 
00216 class StateIOUnixStream: public StateInUnixStream, public StateOutUnixStream {
00217   public:
00218     StateIOUnixStream();
00219     ~StateIOUnixStream();
00220   };
00221 
00222 // ////////////////////////////////////////////////////////////
00223 
00224 class StateOutUnixDGram : virtual public UnixDGramSocket, public StateOut {
00225   protected:
00226     int put_array_void(const void*,int);
00227   public:
00228     StateOutUnixDGram();
00229     ~StateOutUnixDGram();
00230   };
00231 
00232 class StateInUnixDGram : virtual public UnixDGramSocket, public StateIn {
00233   protected:
00234     int get_array_void(void*,int);
00235   public:
00236     StateInUnixDGram();
00237     ~StateInUnixDGram();
00238   };
00239 
00240 class StateIOUnixDGram : public StateInUnixDGram, public StateOutUnixDGram {
00241   public:
00242     StateIOUnixDGram();
00243     ~StateIOUnixDGram();
00244   };
00245 
00246 #endif
00247 
00248 // Local Variables:
00249 // mode: c++
00250 // c-file-style: "ETS"
00251 // End:

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.