Responsive image

Items For Publisher: mz2Vsd9nfBjwcN38UNhAxs1fFve8SUqG36

Time(UTC) Record Key Record Value Raw Data Publisher Transaction
Tue, 29 Jan 2019 11:13:38 +0000 cistest #include #include #include #include #include #include #include #include #include #include #define PORT 8080 static int port = 8080; int pid; //void sig_handler(int); void sig_handler(int sig) { printf("\n Inside signal handling"); system("./test"); //switch (sig) { //case SIGINT: //printf("\n Inside signal handling"); //kill(pid,SIGINT); //default: // fprintf(stderr, "wasn't expecting that!\n"); //abort(); //} } void main(int argc, char const *argv[]) { int server_fd, new_socket, valread; struct sockaddr_in address; int opt = 1; int addrlen = sizeof(address); char buffer[1024] = {0}; char *hello = "Hello from server"; printf("Command line argument %s",argv[1]); // Creating socket file descriptor printf("Process restarting "); if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) { perror("socket failed"); exit(EXIT_FAILURE); } // Forcefully attaching socket to the port 8080 if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt))) { perror("setsockopt"); exit(EXIT_FAILURE); } address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons( port ); // Forcefully attaching socket to the port 8080 if (bind(server_fd, (struct sockaddr *)&address, sizeof(address))<0) { perror("bind failed"); pid=system("ps aux | grep ./test"); kill(pid,0); port = 8080; system("./test"); exit(EXIT_FAILURE); } if (listen(server_fd, 3) < 0) { perror("listen"); exit(EXIT_FAILURE); } signal(SIGUSR1, sig_handler); kill(system("pidof test"),SIGUSR1); printf("Atfer kill process"); //system("./test"); if ((new_socket = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen))<0) { perror("accept"); exit(EXIT_FAILURE); } valread = read( new_socket , buffer, 1024); printf("%s\n",buffer ); send(new_socket , hello , strlen(hello) , 0 ); printf("Hello message sent\n"); } 2415 bytes mz2Vsd9nfBjwcN38UNhAxs1fFve8SUqG36 d4b27faa0a7b4178203e3e8cad13e490f7d1574fb71c958eeab68cba50cea6b1