inprogress

This commit is contained in:
Erik Frojdh 2019-05-15 09:12:14 +02:00
parent bf0847e967
commit 9d5848d0d6
2 changed files with 16 additions and 19 deletions

View File

@ -11,7 +11,7 @@
class MySocketTCP; class MySocketTCP;
class ServerInterface; class ServerInterface;
class slsReceiverImplementation; class slsReceiverImplementation;
#include "ServerSocket.h"
/** /**
@ -113,7 +113,7 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
int function_table(); int function_table();
/** Decodes Function */ /** Decodes Function */
int decode_function(); int decode_function(sls::DataSocket &socket);
/** function not implemented for specific detector */ /** function not implemented for specific detector */
void functionNotImplemented(); void functionNotImplemented();

View File

@ -5,6 +5,7 @@
#include "slsReceiverTCPIPInterface.h" #include "slsReceiverTCPIPInterface.h"
#include "MySocketTCP.h" #include "MySocketTCP.h"
#include "ServerSocket.h"
#include "ServerInterface.h" #include "ServerInterface.h"
#include "slsReceiver.h" #include "slsReceiver.h"
#include "slsReceiverImplementation.h" #include "slsReceiverImplementation.h"
@ -12,11 +13,10 @@
#include "versionAPI.h" #include "versionAPI.h"
#include <array> #include <array>
#include <cstdlib> //EXIT
#include <cstdlib> #include <cstdlib>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <memory> //unique_ptr #include <memory>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <syscall.h> #include <syscall.h>
@ -24,13 +24,9 @@
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() { slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
stop(); stop();
if(mySock) {
delete mySock; delete mySock;
mySock=nullptr; mySock=nullptr;
}
delete interface; delete interface;
delete receiver; delete receiver;
} }
@ -79,9 +75,7 @@ int slsReceiverTCPIPInterface::start(){
return FAIL; return FAIL;
} }
tcpThreadCreated = true; tcpThreadCreated = true;
//#ifdef VERYVERBOSE
FILE_LOG(logDEBUG) << "TCP Server thread created successfully."; FILE_LOG(logDEBUG) << "TCP Server thread created successfully.";
//#endif
return OK; return OK;
} }
@ -142,10 +136,13 @@ void slsReceiverTCPIPInterface::startTCPServer(){
int ret = OK; int ret = OK;
while(true) { while(true) {
if(mySock->Connect() >= 0){ auto server = sls::ServerSocket(portNumber);
ret = decode_function(); auto socket = server.accept();
mySock->Disconnect(); ret = decode_function(socket);
} // if(mySock->Connect() >= 0){
// ret = decode_function();
// mySock->Disconnect();
// }
//if tcp command was to exit server //if tcp command was to exit server
if(ret == GOODBYE){ if(ret == GOODBYE){
@ -242,7 +239,7 @@ int slsReceiverTCPIPInterface::function_table(){
int slsReceiverTCPIPInterface::decode_function(){ int slsReceiverTCPIPInterface::decode_function(sls::DataSocket &socket){
ret = FAIL; ret = FAIL;
int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum)); int n = mySock->ReceiveDataOnly(&fnum,sizeof(fnum));
if (n <= 0) { if (n <= 0) {