c++ socket binary file
<p>i have this function to get the content of file , </p>

<pre><code>#define BUFSIZE 512

vector&lt;int&gt; getContFile(char* pFile) {
        ifstream vCin(pFile, ios::binary);
        ifstream::pos_type size;
        // get vLength of file:
        vCin.seekg(0, ios::end);
        size = vCin.tellg();
        vCin.seekg(0, ios::beg);
        vector&lt;int&gt; vTmp;
        for (int i = 0; i &lt; size; i++)
            vTmp.push_back(vCin.get());
        vCin.close();
        return vTmp;
    }
</code></pre>

<p>and this to send to the server</p>

<pre><code> void SendFile() {
        SendS("upFileUser");
        int i;
        vector&lt;int&gt; vTmp = getContFile("/usr/home/alex/Desktop/eval.tar");
        for (i = 0; i &lt; vTmp.size(); i += BUFSIZE) {
            char *vBuff = new char[BUFSIZE];
            for (int j = i; j &lt; BUFSIZE; j++)
                vBuff[j] = (char(vTmp[i]));
            SendS(vBuff);
            }
        if (i &lt; (vTmp.size() - 1)) {
            char *vBuff = new char[vTmp.size() - i];
            for (int j = 0; j &lt; vTmp.size() - i; j++)
                vBuff[j + i] = (char(vTmp[j + i]));
            SendS(vBuff);
        }
        sendS("endOfFileTransmision");
    }

    void SendS(char* pSir) {
        int vLen = strlen(pSir);
        write(pSocket, &amp;vLen, sizeof (int));
        write(pSocket, pSir, vLen);
    }
</code></pre>

<p>this is the receve function</p>

<pre><code> char* reciveS() {
        char* vTmp;
         int vCt = 0;
        read(pSocket, &amp;vCt, sizeof (vCt));
        if (vCt != 0) {
            vTmp = new char[vCt];
            read(vSocket, vTmp, vCt);
        } else {
            vTmp = NULL;    
        }
        return vTmp;
    } 

bool receveFile(void) {
 char* vReceve = reciveS();
    if (strcmp(vReceve, "upFileUser") == 0)
{
    ofstream vCoutFile;
    vCoutFile.open("data2.tar", ios::out | ios::binary);
    while (true) {
        char *vTmp = new char[BUFSIZ];
        vTmp = reciveS();
        cout&lt;&lt;vTmp;
        if (strcmp(vTmp, "endOfFileTransmision") == 0) break;
        else {
            cout &lt;&lt; vTmp;
            vCoutFile &lt;&lt; vTmp;
        }
    }
    vCoutFile.close();
}
}
</code></pre>

<p>and the result are a broke pipe(i run this to freebsd 6.4 amd with g++ compiler) , so what i miss , the connection are good i can transfer text from client to server and reverse  the problem are with binary file</p>
