sender.c
int send_tcp(char * host, int port, char * packet, unsigned long packet_len){
    int sock = 0;
    struct sockaddr_in serv_addr;

	if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){
		fatal("[!] Error: Could not create socket: %s\n", strerror(errno));
	}

	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons(port);
    inet_pton(AF_INET, host, &serv_addr.sin_addr);
    

    int c = connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
	if(c < 0){
		printf("[!] Error: Could not connect: %s errno: %d\n", strerror(errno), errno);
        if(errno == ECONNRESET){
            close(sock);
            return 0; // just skip this testcase
        }
        else{
            close(sock);
		    return -1;
        }
	}

    if(fuzz.is_tls){
        return 0;
    }
    else{
        callback_pre_send(sock, packet, packet_len); // user defined callback
        fcntl(sock, F_SETFL, O_RDONLY|O_NONBLOCK);
        if(write(sock, packet, packet_len) < 0){
                printf("[!] Error: write() error: %s errno: %d\n", strerror(errno), errno);
        }
        callback_post_send(sock); // user defined callback
    }
    

    if(fuzz.destroy){
        destroy_socket(sock);
    }
    else{
        close(sock);
    }

    return 0;
}
/*
 *	send a char array down a
 *	tcp socket.
*/
send a char array down a
tcp socket.
send a char array down a tcp socket .
int send_tcp(char * host, int port, char * packet, unsigned long packet_len){
    int sock = 0;
    struct sockaddr_in serv_addr;
	if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){
		fatal("[!] Error: Could not create socket: %s\n", strerror(errno));
	}
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_port = htons(port);
    inet_pton(AF_INET, host, &serv_addr.sin_addr);
    int c = connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
	if(c < 0){
		printf("[!] Error: Could not connect: %s errno: %d\n", strerror(errno), errno);
        if(errno == ECONNRESET){
            close(sock);
            return 0; 
        }
        else{
            close(sock);
		    return -1;
        }
	}
    if(fuzz.is_tls){
        return 0;
    }
    else{
        callback_pre_send(sock, packet, packet_len); 
        fcntl(sock, F_SETFL, O_RDONLY|O_NONBLOCK);
        if(write(sock, packet, packet_len) < 0){
                printf("[!] Error: write() error: %s errno: %d\n", strerror(errno), errno);
        }
        callback_post_send(sock); 
    }
    if(fuzz.destroy){
        destroy_socket(sock);
    }
    else{
        close(sock);
    }
    return 0;
}
int send_tcp ( char * host , int port , char * packet , unsigned long packet_len ) { int sock = 0 ; struct sockaddr_in serv_addr ; if ( ( sock = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { fatal ( " \n " , strerror ( errno ) ) ; } serv_addr . sin_family = AF_INET ; serv_addr . sin_port = htons ( port ) ; inet_pton ( AF_INET , host , & serv_addr . sin_addr ) ; int c = connect ( sock , ( struct sockaddr * ) & serv_addr , sizeof ( serv_addr ) ) ; if ( c < 0 ) { printf ( " \n " , strerror ( errno ) , errno ) ; if ( errno == ECONNRESET ) { close ( sock ) ; return 0 ; } else { close ( sock ) ; return -1 ; } } if ( fuzz . is_tls ) { return 0 ; } else { callback_pre_send ( sock , packet , packet_len ) ; fcntl ( sock , F_SETFL , O_RDONLY | O_NONBLOCK ) ; if ( write ( sock , packet , packet_len ) < 0 ) { printf ( " \n " , strerror ( errno ) , errno ) ; } callback_post_send ( sock ) ; } if ( fuzz . destroy ) { destroy_socket ( sock ) ; } else { close ( sock ) ; } return 0 ; }
send a char array down a
      tcp socket.
send a char array down a tcp socket .
// just skip this testcase // user defined callback // user defined callback