mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@333 951219d9-93cf-4727-9268-0efd64621fa3
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
|
|
//version 1.0, base development, Ian 19/01/09
|
|
|
|
|
|
#include "MySocketTCP.h"
|
|
#include <string.h>
|
|
#include <iostream>
|
|
#include <cstdio>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int MySocketTCP::SendData(void* buf,int length){//length in characters
|
|
int ndata = SendDataAndKeepConnection(buf,length);
|
|
Disconnect();
|
|
return ndata;
|
|
}
|
|
|
|
int MySocketTCP::SendDataAndKeepConnection(void* buf,int length){//length in characters
|
|
if(last_keep_connection_open_action_was_a_send) Disconnect(); //to keep a structured data flow;
|
|
|
|
Connect();
|
|
int total_sent=SendDataOnly(buf,length);
|
|
last_keep_connection_open_action_was_a_send=1;
|
|
return total_sent;
|
|
}
|
|
|
|
|
|
|
|
|
|
int MySocketTCP::ReceiveData(void* buf,int length){//length in characters
|
|
int ndata = ReceiveDataAndKeepConnection(buf,length);
|
|
Disconnect();
|
|
return ndata;
|
|
}
|
|
|
|
int MySocketTCP::ReceiveDataAndKeepConnection(void* buf,int length){//length in characters
|
|
if(!last_keep_connection_open_action_was_a_send) Disconnect(); //to a keep structured data flow;
|
|
|
|
Connect();
|
|
// should preform two reads one to receive incomming char count
|
|
int total_received=ReceiveDataOnly(buf,length);
|
|
last_keep_connection_open_action_was_a_send=0;
|
|
return total_received;
|
|
}
|
|
|