mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-11 15:20:01 +02:00
removing unnecessary prints
This commit is contained in:
parent
52f83b9249
commit
5dd5c250f3
@ -60,7 +60,6 @@ class sockaddr_in;
|
|||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#include "ansi.h"
|
|
||||||
#include <stdlib.h> /******exit */
|
#include <stdlib.h> /******exit */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -71,7 +70,6 @@ class sockaddr_in;
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <signal.h> //SIGINT
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -127,7 +125,6 @@ typedef struct
|
|||||||
struct hostent *hostInfo = gethostbyname(host_ip_or_name);
|
struct hostent *hostInfo = gethostbyname(host_ip_or_name);
|
||||||
if (hostInfo == NULL){
|
if (hostInfo == NULL){
|
||||||
cerr << "Exiting: Problem interpreting host: " << host_ip_or_name << "\n";
|
cerr << "Exiting: Problem interpreting host: " << host_ip_or_name << "\n";
|
||||||
cprintf(RED,"Exiting: Problem interpreting host:%s\n",host_ip_or_name);
|
|
||||||
} else {
|
} else {
|
||||||
// Set some fields in the serverAddress structure.
|
// Set some fields in the serverAddress structure.
|
||||||
serverAddress.sin_family = hostInfo->h_addrtype;
|
serverAddress.sin_family = hostInfo->h_addrtype;
|
||||||
@ -137,7 +134,6 @@ typedef struct
|
|||||||
socketDescriptor=0; //You can use send and recv, //would it work?????
|
socketDescriptor=0; //You can use send and recv, //would it work?????
|
||||||
}
|
}
|
||||||
clientAddress_length=sizeof(clientAddress);
|
clientAddress_length=sizeof(clientAddress);
|
||||||
cprintf(MAGENTA, "client socket created %d \n",socketDescriptor,protocol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +176,6 @@ typedef struct
|
|||||||
nsent(0),
|
nsent(0),
|
||||||
total_sent(0)
|
total_sent(0)
|
||||||
{
|
{
|
||||||
signal(SIGCHLD,SIG_IGN);
|
|
||||||
//memset(&serverAddress, 0, sizeof(sockaddr_in));
|
//memset(&serverAddress, 0, sizeof(sockaddr_in));
|
||||||
// memset(&clientAddress, 0, sizeof(sockaddr_in));
|
// memset(&clientAddress, 0, sizeof(sockaddr_in));
|
||||||
// serverAddress = {0};
|
// serverAddress = {0};
|
||||||
@ -210,12 +205,10 @@ typedef struct
|
|||||||
|
|
||||||
|
|
||||||
socketDescriptor = socket(AF_INET, getProtocol(),0); //tcp
|
socketDescriptor = socket(AF_INET, getProtocol(),0); //tcp
|
||||||
cprintf(MAGENTA, "socket created %d protocol:%d\n",socketDescriptor,protocol);
|
|
||||||
|
|
||||||
|
|
||||||
if (socketDescriptor < 0) {
|
if (socketDescriptor < 0) {
|
||||||
cerr << "Can not create socket "<<endl;
|
cerr << "Can not create socket "<<endl;
|
||||||
cprintf(RED,"Can not create socket \n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +230,6 @@ typedef struct
|
|||||||
int val=1;
|
int val=1;
|
||||||
if (setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(int)) == -1) {
|
if (setsockopt(socketDescriptor,SOL_SOCKET,SO_REUSEADDR,&val,sizeof(int)) == -1) {
|
||||||
cerr << "setsockopt" << endl;
|
cerr << "setsockopt" << endl;
|
||||||
cprintf(RED,"setsockopt \n");
|
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -248,7 +240,6 @@ typedef struct
|
|||||||
if((p == UDP) && (setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &val, sizeof(int)) == -1))
|
if((p == UDP) && (setsockopt(socketDescriptor, SOL_SOCKET, SO_RCVBUF, &val, sizeof(int)) == -1))
|
||||||
{
|
{
|
||||||
cerr << "WARNING:Could not set socket receive buffer size" << endl;
|
cerr << "WARNING:Could not set socket receive buffer size" << endl;
|
||||||
cprintf(RED,"WARNING:Could not set socket receive buffer size \n");
|
|
||||||
//socketDescriptor=-1;
|
//socketDescriptor=-1;
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
@ -257,7 +248,6 @@ typedef struct
|
|||||||
|
|
||||||
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
if(bind(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||||
cerr << "Can not bind socket "<< endl;
|
cerr << "Can not bind socket "<< endl;
|
||||||
cprintf(RED,"Can not bind socket \n");
|
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -341,7 +331,6 @@ typedef struct
|
|||||||
if (socketDescriptor>0) {
|
if (socketDescriptor>0) {
|
||||||
if ((file_des = accept(socketDescriptor,(struct sockaddr *) &clientAddress, &clientAddress_length)) < 0) {
|
if ((file_des = accept(socketDescriptor,(struct sockaddr *) &clientAddress, &clientAddress_length)) < 0) {
|
||||||
cerr << "Error: with server accept, connection refused"<<endl;
|
cerr << "Error: with server accept, connection refused"<<endl;
|
||||||
cprintf(RED,"Error: with server accept, connection refused");
|
|
||||||
switch(errno) {
|
switch(errno) {
|
||||||
case EWOULDBLOCK:
|
case EWOULDBLOCK:
|
||||||
printf("ewouldblock eagain\n");
|
printf("ewouldblock eagain\n");
|
||||||
@ -389,7 +378,6 @@ typedef struct
|
|||||||
printf("unknown error\n");
|
printf("unknown error\n");
|
||||||
}
|
}
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
cprintf(RED, "file des NOT connected %d \n",file_des);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||||
@ -397,7 +385,6 @@ typedef struct
|
|||||||
cout << "client connected "<< file_des << endl;
|
cout << "client connected "<< file_des << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cprintf(MAGENTA, "file des connected %d \n",file_des);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -412,17 +399,14 @@ typedef struct
|
|||||||
// SetTimeOut(10);
|
// SetTimeOut(10);
|
||||||
if (socketDescriptor < 0){
|
if (socketDescriptor < 0){
|
||||||
cerr << "Can not create socket "<<endl;
|
cerr << "Can not create socket "<<endl;
|
||||||
cprintf(RED, "Can not create socket in accept\n");
|
|
||||||
file_des = socketDescriptor;
|
file_des = socketDescriptor;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(connect(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
if(connect(socketDescriptor,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||||
cerr << "Can not connect to socket "<<endl;
|
cerr << "Can not connect to socket "<<endl;
|
||||||
cprintf(RED, "Can not connect socket in accept\n");
|
|
||||||
file_des = -1;
|
file_des = -1;
|
||||||
} else{
|
} else{
|
||||||
file_des = socketDescriptor;
|
file_des = socketDescriptor;
|
||||||
cprintf(MAGENTA, "file des connected %d \n",file_des);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,8 +429,8 @@ typedef struct
|
|||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/*
|
|
||||||
close(socketDescriptor);
|
/* close(socketDescriptor);
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
if(is_a_server){
|
if(is_a_server){
|
||||||
if(file_des>=0){
|
if(file_des>=0){
|
||||||
@ -459,16 +443,10 @@ typedef struct
|
|||||||
|
|
||||||
if(file_des>=0){ //then was open
|
if(file_des>=0){ //then was open
|
||||||
if(is_a_server){
|
if(is_a_server){
|
||||||
// cprintf(MAGENTA, "file_des disconnected %d \n",file_des);
|
close(file_des);
|
||||||
if(close(file_des))
|
|
||||||
cprintf(RED,"file_des not disconnected %d\n", file_des);
|
|
||||||
// cprintf(MAGENTA, "file_des disconnected %d \n",file_des);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//cprintf(MAGENTA, "socketDescriptor disconnected %d \n",socketDescriptor);
|
close(socketDescriptor);
|
||||||
if(close(socketDescriptor))
|
|
||||||
cprintf(RED,"socketDescriptor not disconnected %d\n", file_des);
|
|
||||||
// cprintf(MAGENTA, "socketDescriptor disconnected %d \n",socketDescriptor);
|
|
||||||
socketDescriptor=-1;
|
socketDescriptor=-1;
|
||||||
}
|
}
|
||||||
file_des=-1;
|
file_des=-1;
|
||||||
|
@ -746,7 +746,6 @@ int UDPBaseImplementation::createUDPSockets(){ FILE_LOG(logDEBUG) << __AT__ << "
|
|||||||
cout<<"warning:eth is empty.listening to all"<<endl;
|
cout<<"warning:eth is empty.listening to all"<<endl;
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
cprintf(RED, "gonna try listening to all\n");
|
|
||||||
udpSocket[i] = new genericSocket(server_port[i],genericSocket::UDP,bufferSize);
|
udpSocket[i] = new genericSocket(server_port[i],genericSocket::UDP,bufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -755,7 +754,6 @@ int UDPBaseImplementation::createUDPSockets(){ FILE_LOG(logDEBUG) << __AT__ << "
|
|||||||
cout<<"eth:"<<eth<<endl;
|
cout<<"eth:"<<eth<<endl;
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
cprintf(RED, "gonna try listening to all\n");
|
|
||||||
udpSocket[i] = new genericSocket(server_port[i],genericSocket::UDP,bufferSize,eth);
|
udpSocket[i] = new genericSocket(server_port[i],genericSocket::UDP,bufferSize,eth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1058,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
|||||||
cout<<"warning:eth is empty.listening to all"<<endl;
|
cout<<"warning:eth is empty.listening to all"<<endl;
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
cprintf(YELLOW, "gonna try listening to all\n");
|
// cprintf(YELLOW, "gonna try listening to all\n");
|
||||||
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize);
|
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1067,7 +1067,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
|||||||
cout<<"eth:"<<eth<<endl;
|
cout<<"eth:"<<eth<<endl;
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
cprintf(YELLOW, "gonna try focussed\n");
|
// cprintf(YELLOW, "gonna try focussed\n");
|
||||||
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize,eth);
|
udpSocket[i] = new genericSocket(port[i],genericSocket::UDP,bufferSize,eth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1078,7 +1078,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
|||||||
iret = udpSocket[i]->getErrorStatus();
|
iret = udpSocket[i]->getErrorStatus();
|
||||||
if(!iret){
|
if(!iret){
|
||||||
cout << "UDP port opened at port " << port[i] << endl;
|
cout << "UDP port opened at port " << port[i] << endl;
|
||||||
cprintf(YELLOW, "socket of port %d descriptor:%d\n",i,udpSocket[i]->getsocketDescriptor());
|
//cprintf(YELLOW, "socket of port %d descriptor:%d\n",i,udpSocket[i]->getsocketDescriptor());
|
||||||
}else{
|
}else{
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(BG_RED,"Could not create UDP socket on port %d error: %d\n", port[i], iret);
|
cprintf(BG_RED,"Could not create UDP socket on port %d error: %d\n", port[i], iret);
|
||||||
@ -1411,7 +1411,7 @@ int UDPStandardImplementation::createNewFile(){
|
|||||||
//close
|
//close
|
||||||
if(sfilefd){
|
if(sfilefd){
|
||||||
if(fclose(sfilefd)){
|
if(fclose(sfilefd)){
|
||||||
cprintf(YELLOW, "file clsoe problem %d\n",fileno(sfilefd));
|
cprintf(RED, "file close problem %d\n",fileno(sfilefd));
|
||||||
fclose(sfilefd);
|
fclose(sfilefd);
|
||||||
}
|
}
|
||||||
sfilefd = NULL;
|
sfilefd = NULL;
|
||||||
@ -1430,9 +1430,8 @@ int UDPStandardImplementation::createNewFile(){
|
|||||||
//setting buffer
|
//setting buffer
|
||||||
setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE);
|
setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE);
|
||||||
|
|
||||||
cprintf(YELLOW, "file value:%d\n",fileno(sfilefd));
|
//cprintf(YELLOW, "file value:%d\n",fileno(sfilefd));
|
||||||
|
|
||||||
//cprintf(YELLOW, "file valuex:%d",(int)sfilefd);
|
|
||||||
//printing packet losses and file names
|
//printing packet losses and file names
|
||||||
if(!packetsCaught)
|
if(!packetsCaught)
|
||||||
cout << savefilename << endl;
|
cout << savefilename << endl;
|
||||||
@ -1474,12 +1473,12 @@ void UDPStandardImplementation::closeFile(int ithr){
|
|||||||
|
|
||||||
if(!dataCompression){
|
if(!dataCompression){
|
||||||
if(sfilefd){
|
if(sfilefd){
|
||||||
//#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cprintf(YELLOW, "gonna close file:%d\n",fileno(sfilefd));
|
cprintf(YELLOW, "gonna close file:%d\n",fileno(sfilefd));
|
||||||
//#endif
|
#endif
|
||||||
if(fclose(sfilefd))
|
if(fclose(sfilefd))
|
||||||
perror("close ERRROR");
|
perror("file close ERROR");
|
||||||
cprintf(YELLOW, "check close file:%d\n",fileno(sfilefd));
|
//cprintf(YELLOW, "check close file:%d\n",fileno(sfilefd));
|
||||||
sfilefd = NULL;
|
sfilefd = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user