mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
merging with master
This commit is contained in:
@ -60,7 +60,6 @@ class sockaddr_in;
|
||||
#include <ifaddrs.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> /******exit */
|
||||
|
||||
#include <unistd.h>
|
||||
@ -71,6 +70,8 @@ class sockaddr_in;
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define DEFAULT_PACKET_SIZE 1286
|
||||
@ -272,7 +273,11 @@ typedef struct
|
||||
if (socketDescriptor >= 0){ \
|
||||
close(socketDescriptor); \
|
||||
} \
|
||||
file_des=-1; \
|
||||
if(is_a_server and getProtocol() == TCP){\
|
||||
if(file_des>0)\
|
||||
close(file_des);\
|
||||
}
|
||||
file_des=-1; \
|
||||
serverAddress.sin_port=-1; \
|
||||
};
|
||||
|
||||
@ -376,6 +381,7 @@ typedef struct
|
||||
#ifdef VERY_VERBOSE
|
||||
cout << "client connected "<< file_des << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -392,7 +398,6 @@ typedef struct
|
||||
cerr << "Can not create socket "<<endl;
|
||||
file_des = socketDescriptor;
|
||||
} else {
|
||||
|
||||
if(connect(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||
cerr << "Can not connect to socket "<<endl;
|
||||
file_des = -1;
|
||||
@ -413,6 +418,16 @@ typedef struct
|
||||
|
||||
int getsocketDescriptor(){return socketDescriptor;};
|
||||
|
||||
|
||||
void exitServer(){
|
||||
if(is_a_server){
|
||||
if (socketDescriptor>=0){
|
||||
close(socketDescriptor);
|
||||
socketDescriptor = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @short free connection */
|
||||
void Disconnect(){
|
||||
if (protocol==UDP){
|
||||
@ -435,9 +450,8 @@ typedef struct
|
||||
|
||||
|
||||
void ShutDownSocket(){
|
||||
while(!shutdown(socketDescriptor, SHUT_RDWR));
|
||||
close(socketDescriptor);
|
||||
socketDescriptor = -1;
|
||||
while(!shutdown(socketDescriptor, SHUT_RDWR));
|
||||
Disconnect();
|
||||
};
|
||||
|
||||
|
||||
@ -513,6 +527,9 @@ typedef struct
|
||||
}
|
||||
mac[sizeof(mac)-1]='\0';
|
||||
|
||||
if(sock!=1){
|
||||
close(sock);
|
||||
}
|
||||
return string(mac);
|
||||
|
||||
};
|
||||
@ -534,6 +551,9 @@ typedef struct
|
||||
strncpy(addr,p,sizeof(addr)-1);
|
||||
addr[sizeof(addr)-1]='\0';
|
||||
|
||||
if(sock!=1){
|
||||
close(sock);
|
||||
}
|
||||
return string(addr);
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user