mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 07:17:13 +02:00
converted to c++
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@347 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
56
slsDetectorSoftware/slsReceiver/slsReceiver.cpp
Normal file
56
slsDetectorSoftware/slsReceiver/slsReceiver.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
|
||||
#include "receiver_defs.h"
|
||||
#include "MySocketTCP.h"
|
||||
#include "slsReceiver_funcs.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int portno = DEFAULT_PORTNO+2;
|
||||
int retval = slsDetectorDefs::OK;
|
||||
|
||||
MySocketTCP *socket = new MySocketTCP(portno);
|
||||
if (socket->getErrorStatus())
|
||||
return -1;
|
||||
|
||||
//assign function table
|
||||
slsReceiverFuncs *receiver = new slsReceiverFuncs(socket);
|
||||
#ifdef VERBOSE
|
||||
cout << "Function table assigned.\n Ready..." << endl;
|
||||
#endif
|
||||
|
||||
//waits for connection
|
||||
while(retval!=GOODBYE) {
|
||||
#ifdef VERBOSE
|
||||
cout<< endl;
|
||||
#endif
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "Waiting for client call" << endl;
|
||||
#endif
|
||||
if(socket->Connect()>=0){
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "Conenction accepted" << endl;
|
||||
#endif
|
||||
retval = receiver->decode_function();
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "function executed" << endl;
|
||||
#endif
|
||||
socket->Disconnect();
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "connection closed" << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delete socket;
|
||||
cout << "Goodbye!" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user