Q:

How to send an object file .o via ssl and socket

I need to send an object file from my client to the server program.
I tried reading the file, storing it into a buffer, sent the buffer over the ssl and wrote to a file in the server program. 
This did not work for .o files.  This was the out put ELF.
This is some of my code
Read file
void readFile(char filename[])  
{
    FILE        *input_file;
    char        line[BUFSIZ];

    input_file = fopen(filename, "r");

    if(input_file == NULL){
        printf("cannot open input_file '%s'\n", filename );
        exit(EXIT_FAILURE);
    }

while (fgets(line,sizeof line, input_file) != NULL) {

    for(int i = 0; i<strlen(line); i++){
        current_file[i] = line[i];
    }   
}}

Client sends the file
    readFile(filename);
    ctx = InitCTX();  
    server = OpenConnection(hostname, atoi(portnum));  
    ssl = SSL_new(ctx);      /* create new SSL connection state */  
    SSL_set_fd(ssl, server);    /* attach the socket descriptor */  
    if ( SSL_connect(ssl) == FAIL )   /* perform the connection */  
        ERR_print_errors_fp(stderr);  
    else  
    {   

        printf("Connected with %s encryption\n", SSL_get_cipher(ssl));  
        ShowCerts(ssl);        /* get any certs */  
        SSL_write(ssl, current_file, strlen(current_file));

Is it possible to read object file, and then store it in a buffer? 
Is there other methods to send these file?

A:

There's nothing 'special' about a .o file, it's simply a series of bytes stored on disc, with a filename and extension assigned to it.
My guess would be that you need to handle the file differently from what you have there, as it's going to be binary data. It won't have the 'usual' concept of lines that you're currently reading in.
I'd have a look at the following:
http://www.linuxquestions.org/questions/programming-9/c-howto-read-binary-file-into-buffer-172985/
Try reading then writing your file locally first to check whether it's being corrupted in transit or in the local I/O routines?

