edited generic socket for udp socket, prob:gap in files when using smaller buffers

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@357 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-11-22 13:55:37 +00:00
parent c02075dc12
commit a781ca3422
4 changed files with 11 additions and 8 deletions

View File

@ -515,8 +515,10 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
break; break;
case UDP: case UDP:
if (socketDescriptor<0) return -1; if (socketDescriptor<0) return -1;
while(length>0){ // while(length>0){
nsending = (length>packet_size) ? packet_size:length; for(int i=0;i<2;i++){
nsending=packet_size;
//nsending = (length>packet_size) ? packet_size:length;
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length); nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
if(!nsent) break; if(!nsent) break;
length-=nsent; length-=nsent;

View File

@ -37,6 +37,7 @@ int main(int argc, char *argv[])
if(ret==slsDetectorDefs::FAIL) if(ret==slsDetectorDefs::FAIL)
return -1; return -1;
#ifdef VERBOSE #ifdef VERBOSE
cout << "Function table assigned." << endl; cout << "Function table assigned." << endl;
#endif #endif

View File

@ -111,7 +111,7 @@ void slsReceiverFunctionList::closeFile(int p){
cout << "Closing file and Exiting." << endl; cout << "Closing file and Exiting." << endl;
fclose(sfilefd); fclose(sfilefd);
} }
exit(0); //exit(0);
} }

View File

@ -6,7 +6,7 @@
#include "slsReceiver_funcs.h" #include "slsReceiver_funcs.h"
#include "slsReceiverFunctionList.h" #include "slsReceiverFunctionList.h"
#include <signal.h> // SIGINT //#include <signal.h> //SIGINT
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -15,6 +15,9 @@
using namespace std; using namespace std;
slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname): slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname):
socket(mySocket), socket(mySocket),
ret(OK), ret(OK),
@ -197,10 +200,7 @@ int slsReceiverFuncs::M_nofunc(){
/* /*
void slsReceiverFuncs::closeFile(int p){ void slsReceiverFuncs::closeFile(int p){
//if(socket) //if(socket)
slsReceiverFunctionList::closeFile(0); slsReceiverFunctionList::closeFile();
socket->Disconnect();//non static
delete socket;
exit(0);
} }
*/ */