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

View File

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