TCP_Socket.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.4 $
00022 // $Date: 2005/11/23 23:43:47 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/channel/TCP_Socket.h,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Created: 11/96
00028 // Revision: A
00029 //
00030 // Purpose: This file contains the class definition for TCP_Socket.
00031 // TCP_Socket is a sub-class of channel. It is implemented with Berkeley
00032 // stream sockets using the TCP protocol. Messages delivery is garaunteed. 
00033 // Communication is full-duplex between a pair of connected sockets.
00034 //
00035 // What: "@(#) TCP_Socket.h, revA"
00036 
00037 #ifndef TCP_Socket_h
00038 #define TCP_Socket_h
00039 
00040 #include <bool.h>
00041 #include <Socket.h>
00042 #include <Channel.h>
00043 #include <SocketAddress.h>
00044 
00045 class TCP_Socket : public Channel
00046 {
00047   public:
00048     TCP_Socket();        
00049     TCP_Socket(unsigned int);    
00050     TCP_Socket(unsigned int other_Port, char *other_InetAddr); 
00051     ~TCP_Socket();
00052 
00053     char *addToProgram(void);
00054     
00055     virtual int setUpConnection(void);
00056 
00057     int setNextAddress(const ChannelAddress &otherChannelAddress);
00058     virtual ChannelAddress *getLastSendersAddress(void){ return 0;};
00059 
00060     int sendObj(int commitTag,
00061                 MovableObject &theObject, 
00062                 ChannelAddress *theAddress =0);
00063     int recvObj(int commitTag,
00064                 MovableObject &theObject, 
00065                 FEM_ObjectBroker &theBroker,
00066                 ChannelAddress *theAddress =0);
00067                 
00068     int sendMsg(int dbTag, int commitTag, 
00069                 const Message &, 
00070                 ChannelAddress *theAddress =0);    
00071     int recvMsg(int dbTag, int commitTag, 
00072                 Message &, 
00073                 ChannelAddress *theAddress =0);        
00074 
00075     int sendMatrix(int dbTag, int commitTag, 
00076                    const Matrix &theMatrix, 
00077                    ChannelAddress *theAddress =0);
00078     int recvMatrix(int dbTag, int commitTag, 
00079                    Matrix &theMatrix, 
00080                    ChannelAddress *theAddress =0);
00081     
00082     int sendVector(int dbTag, int commitTag, 
00083                    const Vector &theVector, ChannelAddress *theAddress =0);
00084     int recvVector(int dbTag, int commitTag, 
00085                    Vector &theVector, 
00086                    ChannelAddress *theAddress =0);
00087     
00088     int sendID(int dbTag, int commitTag, 
00089                const ID &theID, 
00090                ChannelAddress *theAddress =0);
00091     int recvID(int dbTag, int commitTag, 
00092                ID &theID, 
00093                ChannelAddress *theAddress =0);    
00094     
00095   protected:
00096     unsigned int getPortNumber(void) const;
00097     
00098   private:
00099     socket_type sockfd;
00100 
00101     union {
00102       struct sockaddr    addr;
00103       struct sockaddr_in addr_in;
00104     } my_Addr;
00105     union {
00106       struct sockaddr    addr;
00107       struct sockaddr_in addr_in;
00108     } other_Addr;
00109 
00110     socklen_type addrLength;
00111 
00112     unsigned int myPort;
00113     int connectType;
00114 
00115     char add[40];
00116 };
00117 
00118 
00119 #endif 
00120 
00121 
00122 
00123 
00124 
00125 
00126  
00127 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0