UDP_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.3 $
00022 // $Date: 2003/10/15 00:31:47 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/channel/UDP_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 UDP_Socket.
00031 // UDP_Socket is a sub-class of channel. It is implemented with
00032 // Berkeley datagram sockets using the UDP protocol. Messages delivery
00033 // is thus unreliable.
00034 //
00035 // What: "@(#) UDP_Socket.h, revA"
00036 
00037 #ifndef UDP_Socket_h
00038 #define UDP_Socket_h
00039 
00040 #include <Socket.h>
00041 #include <Channel.h>
00042 class SocketAddress;
00043 
00044 class UDP_Socket : public Channel
00045 {
00046   public:
00047     UDP_Socket();
00048     UDP_Socket(unsigned int port);   
00049     UDP_Socket(unsigned int other_Port, char *other_InetAddr);  
00050     ~UDP_Socket();
00051     
00052     char *addToProgram(void);
00053     
00054     virtual int setUpConnection(void);
00055 
00056     int setNextAddress(const ChannelAddress &otherChannelAddress);
00057 
00058     int sendObj(int commitTag,
00059                 MovableObject &theObject, 
00060                 ChannelAddress *theAddress =0);
00061     int recvObj(int commitTag,
00062                 MovableObject &theObject, 
00063                 FEM_ObjectBroker &theBroker,
00064                 ChannelAddress *theAddress =0);
00065                 
00066     int sendMsg(int dbTag, int commitTag, 
00067                 const Message &, 
00068                 ChannelAddress *theAddress =0);    
00069     int recvMsg(int dbTag, int commitTag, 
00070                 Message &, 
00071                 ChannelAddress *theAddress =0);        
00072 
00073     int sendMatrix(int dbTag, int commitTag, 
00074                    const Matrix &theMatrix, 
00075                    ChannelAddress *theAddress =0);
00076     int recvMatrix(int dbTag, int commitTag, 
00077                    Matrix &theMatrix, 
00078                    ChannelAddress *theAddress =0);
00079     
00080     int sendVector(int dbTag, int commitTag, 
00081                    const Vector &theVector, ChannelAddress *theAddress =0);
00082     int recvVector(int dbTag, int commitTag, 
00083                    Vector &theVector, 
00084                    ChannelAddress *theAddress =0);
00085     
00086     int sendID(int dbTag, int commitTag, 
00087                const ID &theID, 
00088                ChannelAddress *theAddress =0);
00089     int recvID(int dbTag, int commitTag, 
00090                ID &theID, 
00091                ChannelAddress *theAddress =0);    
00092 
00093  protected:
00094     unsigned int getPortNumber(void) const;
00095     
00096   private:
00097     int sockfd;
00098     int connectType;
00099     union {
00100           struct sockaddr    addr;
00101           struct sockaddr_in addr_in;
00102     } my_Addr;
00103     union {
00104       struct sockaddr    addr;
00105       struct sockaddr_in addr_in;
00106     } last_Addr;
00107 
00108     socklen_t addrLength;
00109     char *shadow_inetAddr;
00110     unsigned int shadow_port;
00111     unsigned int myPort;    
00112     char add[40];    
00113 };
00114 
00115 #endif 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124  
00125 

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