basic layout

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@575 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2013-05-23 11:35:47 +00:00
parent 385a67e017
commit 19101fd2ec
3 changed files with 966 additions and 3492 deletions

View File

@ -2,9 +2,10 @@
The port number is passed as an argument */ The port number is passed as an argument */
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "slsDetectorServer_defs.h"
#include "communication_funcs.h" #include "communication_funcs.h"
#include "slsDetectorServer_funcs.h" #include "slsDetectorServer_funcs.h"
#include "slsDetectorServer_defs.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -13,84 +14,82 @@
extern int sockfd; extern int sockfd;
void error(char *msg) void error(char *msg){
{ perror(msg);
perror(msg);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[]){
{ int portno, b;
int portno, b; char cmd[100];
char cmd[100]; int retval=OK;
int retval=OK; int sd, fd;
int sd, fd;
#ifdef STOP_SERVER
if (argc==1) {
#endif
portno = DEFAULT_PORTNO;
printf("opening control server on port %d\n",portno );
b=1;
#ifdef STOP_SERVER
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
system(cmd);
} else {
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
printf("could not open stop server: unknown port\n");
return 1;
}
printf("opening stop server on port %d\n",portno);
b=0;
}
#endif
if (argc==1) { init_detector(b); //defined in slsDetectorServer_funcs
portno = DEFAULT_PORTNO;
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
printf("opening control server on port %d\n",portno );
system(cmd);
b=1;
} else {
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
printf("could not open stop server: unknown port\n");
return 1;
}
b=0;
printf("opening stop server on port %d\n",portno);
}
sd=bindSocket(portno); //defined in communication_funcs
sockfd=sd;
init_detector(b); //defined in slsDetectorServer_funcs
if (getServerError(sd)) { //defined in communication_funcs
printf("server error!\n");
return -1;
}
sd=bindSocket(portno); //defined in communication_funcs /* assign function table */
function_table(); //defined in slsDetectorServer_funcs
sockfd=sd;
if (getServerError(sd)) { //defined in communication_funcs
printf("server error!\n");
return -1;
}
/* assign function table */
function_table(); //defined in slsDetectorServer_funcs
#ifdef VERBOSE #ifdef VERBOSE
printf("function table assigned \n"); printf("function table assigned \n");
#endif #endif
/* waits for connection */ /* waits for connection */
while(retval!=GOODBYE) { while(retval!=GOODBYE) {
#ifdef VERBOSE #ifdef VERBOSE
printf("\n"); printf("\n");
#endif #endif
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("Waiting for client call\n"); printf("Waiting for client call\n");
#endif #endif
fd=acceptConnection(sockfd); //defined in communication_funcs fd=acceptConnection(sockfd); //defined in communication_funcs
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("Conenction accepted\n"); printf("Conenction accepted\n");
#endif #endif
if (fd>0) { if (fd>0) {
retval=decode_function(fd); //defined in slsDetectorServer_funcs retval=decode_function(fd); //defined in slsDetectorServer_funcs
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("function executed\n"); printf("function executed\n");
#endif #endif
closeConnection(fd); //defined in communication_funcs closeConnection(fd); //defined in communication_funcs
#ifdef VERY_VERBOSE #ifdef VERY_VERBOSE
printf("connection closed\n"); printf("connection closed\n");
#endif #endif
} }
} }
exitServer(sockfd); //defined in communication_funcs exitServer(sockfd); //defined in communication_funcs
printf("Goodbye!\n"); printf("Goodbye!\n");
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff