34 #if defined (G4VIS_BUILD_DAWN_DRIVER) || defined (G4VIS_USE_DAWN)
38 #if !defined G4FR_CLIENT_SERVER_H
39 #define G4FR_CLIENT_SERVER_H
42 #include<sys/socket.h>
43 #include<netinet/in.h>
55 const char FR_ENV_SERVER_HOST_NAME[] =
"G4DAWN_HOST_NAME" ;
56 const char FR_ENV_NAMED_PIPE_CONNECTION[] =
"G4DAWN_NAMED_PIPE" ;
62 class G4FRClientServer {
64 enum { SEND_BUFMAX = 1024 , RECV_BUFMAX = 1024 };
65 enum { SUN_PATH_MAX = 16 };
68 const char TERMINATOR ;
69 const char END_OF_LINE;
70 char SUN_PATH[ SUN_PATH_MAX ];
74 char fReceivedMessage [ RECV_BUFMAX ];
75 char fSendingMessage [ SEND_BUFMAX ];
79 void Err(
const char*
message ) { perror(message) ;}
80 void SetSendingMessage(
const char*
message )
81 { strcpy( fSendingMessage, message );}
86 int AcceptUnix(){
return 0;}
87 int AcceptINET(){
return 0 ;}
96 G4FRClientServer (
char terminator =
'.' ,
97 char end_line =
'\n' ) ;
98 virtual ~G4FRClientServer () {;}
99 void SetSunPath(
const char* sun_path )
100 { strcpy ( SUN_PATH, sun_path ); }
101 void SetPortNumber(
int port_num )
102 { PORT_NUMBER = port_num ; }
103 void IncrementPortNumber(
int incr = 1 )
104 { PORT_NUMBER += incr ; }
105 const char* GetSendingMessage()
const
106 {
return fSendingMessage ;}
107 int GetSendingMessageLength()
const
108 {
return strlen(fSendingMessage) ;}
109 void SetReceivedMessage(
const char*
message )
110 { strcpy( fReceivedMessage, message );}
111 const char* GetReceivedMessage()
const
112 {
return fReceivedMessage ;}
113 int GetReceivedMessageLength()
const
114 {
return strlen(fReceivedMessage) ;}
115 int GetSofd()
const {
return fSocketFd ; }
116 int GetPortNumber ()
const {
return PORT_NUMBER ; }
117 void ClearReceivedMessage ()
118 { memset(fReceivedMessage,
'\0', RECV_BUFMAX) ; }
120 int IsTerminator(
char ch ) {
return ( ch == TERMINATOR ); }
121 char GetTerminator()
const {
return TERMINATOR ; }
122 int IsEndOfLine (
char ch ) {
return ( ch == END_OF_LINE ); }
123 char GetEndOfLine()
const {
return END_OF_LINE ; }
126 void WaitSendBack(
const char* command_string ) ;
129 virtual void Send (
const char*
message ) ;
130 virtual void SendLine (
const char*
message ) ;
133 virtual void Receive() ;
134 virtual void ReceiveLine() ;
140 #endif //G4VIS_BUILD_DAWN_DRIVER