mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
converted receiver to c++, edited generic socket to include differentclients
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@348 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
3c94d2cb40
commit
af3abff8dd
@ -149,6 +149,11 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
/* myaddr.sin_addr.s_addr = INADDR_ANY; */
|
/* myaddr.sin_addr.s_addr = INADDR_ANY; */
|
||||||
|
|
||||||
|
|
||||||
|
if(serverAddress.sin_port == htons(port_number)){
|
||||||
|
socketDescriptor = -10;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char ip[20];
|
char ip[20];
|
||||||
|
|
||||||
strcpy(ip,"0.0.0.0");
|
strcpy(ip,"0.0.0.0");
|
||||||
@ -251,7 +256,7 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
/** @short returns error status
|
/** @short returns error status
|
||||||
\returns 1 if error
|
\returns 1 if error
|
||||||
*/
|
*/
|
||||||
int getErrorStatus(){if (socketDescriptor<0) return 1; else return 0;};
|
int getErrorStatus(){if (socketDescriptor==-10) return -10; else if (socketDescriptor<0) return 1; else return 0;};
|
||||||
|
|
||||||
|
|
||||||
/** @short etablishes connection; disconnect should always follow
|
/** @short etablishes connection; disconnect should always follow
|
||||||
@ -314,10 +319,12 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
}
|
}
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
else
|
|
||||||
cout << "client connected "<< file_des << endl;
|
cout << "client connected "<< file_des << endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// file_des = socketDescriptor;
|
// file_des = socketDescriptor;
|
||||||
@ -519,6 +526,14 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
cout << "sent "<< total_sent << " Bytes" << endl;
|
cout << "sent "<< total_sent << " Bytes" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
if (total_sent>0)
|
||||||
|
strcpy(thisClientIP,dummyClientIP);
|
||||||
|
|
||||||
|
if (strcmp(lastClientIP,thisClientIP))
|
||||||
|
differentClients=1;
|
||||||
|
else
|
||||||
|
differentClients=0;
|
||||||
|
|
||||||
return total_sent;
|
return total_sent;
|
||||||
|
|
||||||
|
|
||||||
@ -568,6 +583,9 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char lastClientIP[INET_ADDRSTRLEN];
|
||||||
|
char thisClientIP[INET_ADDRSTRLEN];
|
||||||
|
int differentClients;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -587,6 +605,10 @@ protocol(p), is_a_server(0), socketDescriptor(-1),file_des(-1), packet_size(DEFA
|
|||||||
struct sockaddr_in clientAddress, serverAddress;
|
struct sockaddr_in clientAddress, serverAddress;
|
||||||
socklen_t clientAddress_length;
|
socklen_t clientAddress_length;
|
||||||
|
|
||||||
|
|
||||||
|
char dummyClientIP[INET_ADDRSTRLEN];
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int nsending;
|
int nsending;
|
||||||
|
@ -122,8 +122,6 @@ enum {
|
|||||||
|
|
||||||
F_GET_FRAMES_CAUGHT, /**< gets the number of frames caught by receiver */
|
F_GET_FRAMES_CAUGHT, /**< gets the number of frames caught by receiver */
|
||||||
|
|
||||||
F_LOCK_RECEIVER, /**< locks receiver */
|
|
||||||
|
|
||||||
F_GET_FRAME_INDEX, /**< gets the frame index */
|
F_GET_FRAME_INDEX, /**< gets the frame index */
|
||||||
|
|
||||||
F_RESET_FRAMES_CAUGHT /**< resets the frames caught */
|
F_RESET_FRAMES_CAUGHT /**< resets the frames caught */
|
||||||
|
@ -5743,7 +5743,7 @@ int* slsDetector::readFrameFromReceiver(char* fName, int &fIndex){
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::lockReceiver(int lock){
|
int slsDetector::lockReceiver(int lock){
|
||||||
int fnum=F_LOCK_RECEIVER;
|
int fnum=F_LOCK_SERVER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int retval=-1;
|
int retval=-1;
|
||||||
int arg=lock;
|
int arg=lock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user