source: trunk/source/visualization/FukuiRenderer/include/G4FRClientServer.hh @ 1346

Last change on this file since 1346 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4FRClientServer.hh,v 1.7 2006/06/29 21:16:34 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// Satoshi TANAKA, Wed Jul  3 14:13:52 JST 1996
31////////////////////////////////
32///// G4FRClientServer.h  /////
33////////////////////////////////
34
35//=================//
36#if defined (G4VIS_BUILD_DAWN_DRIVER) || defined (G4VIS_USE_DAWN)
37//=================//
38
39
40#if !defined G4FR_CLIENT_SERVER_H
41#define G4FR_CLIENT_SERVER_H
42
43#include<sys/types.h>
44#include<sys/socket.h>
45#include<netinet/in.h>
46#include<arpa/inet.h>
47#include<netdb.h>
48#include<sys/un.h>
49#include<unistd.h>
50#include<stdio.h>
51#include<stdlib.h>
52#include<string.h>
53#include"G4ios.hh"
54
55
56//----- constants
57const  char     FR_ENV_SERVER_HOST_NAME[]       = "G4DAWN_HOST_NAME"  ;
58const  char     FR_ENV_NAMED_PIPE_CONNECTION[]  = "G4DAWN_NAMED_PIPE" ;
59
60        //-----------------------------------//
61        //-----  class G4FRClientServer -----//
62        //-----------------------------------//
63
64class G4FRClientServer { 
65 public:
66        enum { SEND_BUFMAX = 1024 , RECV_BUFMAX = 1024 };
67        enum { SUN_PATH_MAX = 16 };
68
69 protected:     
70        const char              TERMINATOR ;
71        const char              END_OF_LINE;
72        char                    SUN_PATH[ SUN_PATH_MAX ];
73        int                     PORT_NUMBER ;
74        int                     fSocketFd ;
75
76        char            fReceivedMessage [ RECV_BUFMAX ];
77        char            fSendingMessage  [ SEND_BUFMAX ];
78
79 protected:
80
81        void            Err( const char* message ) { perror(message) ;}
82        void            SetSendingMessage( const char* message ) 
83                                { strcpy( fSendingMessage, message );}
84        void            Send() ; // send command in fSendingMessage
85
86 public:       
87                //----- Server
88        int             AcceptUnix(){ return 0;}  // made unfunctioned 
89        int             AcceptINET(){ return 0 ;}  // made unfunctioned 
90
91                //----- Client
92        int             ConnectUnix(); 
93        int             ConnectINET(); 
94
95                //----- Common to server and client
96
97                //---------- (1)
98        G4FRClientServer (      char terminator = '.'           ,
99                                char end_line = '\n'              ) ; 
100        virtual ~G4FRClientServer () {;}
101        void            SetSunPath( const char* sun_path ) 
102                        { strcpy     ( SUN_PATH, sun_path ); }
103        void            SetPortNumber( int port_num ) 
104                        { PORT_NUMBER = port_num ; }
105        void            IncrementPortNumber( int incr = 1 ) 
106                        { PORT_NUMBER += incr ; }
107        const char*     GetSendingMessage() const
108                                { return  fSendingMessage            ;}
109        int             GetSendingMessageLength() const
110                                { return  strlen(fSendingMessage)    ;}
111        void            SetReceivedMessage( const char* message ) 
112                                { strcpy( fReceivedMessage, message );}
113        const char*     GetReceivedMessage() const
114                                { return fReceivedMessage            ;}
115        int             GetReceivedMessageLength() const   
116                                { return strlen(fReceivedMessage)    ;}
117        int             GetSofd() const { return fSocketFd ; }
118        int             GetPortNumber () const { return PORT_NUMBER ; }
119        void            ClearReceivedMessage () 
120                        { memset(fReceivedMessage, '\0', RECV_BUFMAX) ; }
121
122        int             IsTerminator(char ch ) { return ( ch == TERMINATOR ); }
123        char            GetTerminator()  const  { return TERMINATOR ; }
124        int             IsEndOfLine (char ch ) { return ( ch == END_OF_LINE ); }
125        char            GetEndOfLine() const { return END_OF_LINE ; }
126        void            DisConnect();
127        void            Clear();
128        void            WaitSendBack( const char* command_string ) ;
129
130                //---------- (2) send and receive
131        virtual void    Send     ( const char* message ) ; 
132        virtual void    SendLine ( const char* message ) ; 
133                                // Add END_OF_LINE if the message does not
134                                // Terminate with it. And then send the message.
135        virtual void    Receive() ;
136        virtual void    ReceiveLine() ;
137
138}; // G4FRClientServer
139
140
141#endif
142#endif //G4VIS_BUILD_DAWN_DRIVER
143
Note: See TracBrowser for help on using the repository browser.