Recv() issues with delay
===

This question has been asked a number of times, I have noted, but none of the solutions seem to be applicable to me. Before I continue I will post a little bit of code for you: 

    <code>
        
        // Await the response and stream it to the buffer, with a physical limit of 1024 ASCII     characters
        stringstream input;
        char buffer[4096*2];
        while (recv(sock, buffer, sizeof(buffer) - 1, MSG_WAITALL) > 0)
            input << buffer;
        input << '\0';
    
        // Close the TCP connection
        close(sock);
        freehostent(hostInfo);
    </code>

And here is my request: 

    <code>
        string data;
        {
            stringstream bodyStream;
        
            bodyStream
                << "POST /api/translation/translate HTTP/1.1\n"
                << "Host: elfdict.com\n"
                << "Content-Type: application/x-www-form-urlencoded\n"
                << "Content-Length: " << (5 + m_word.length())
                << "\n\nterm=" << m_word;
    
            data = bodyStream.str();
        }
    
        cout << "Sending HTTP request: " << endl << data << endl;

    </code>

I am very new to this sort of programming (and stack overflow- preferring to slog it out and bang my head against a wall until I solve problems myself but I'm lost here!) and would really appreciate help working out why it takes so long! I've looked into setting it up so that it is non-blocking, but had issues getting that to work as expected. Though maybe people here could point me in the right direction, if the non-bocking route is the way I need to go. 

I have seen that a lot of people prefer to use libraries but I want to learn to do this! 

I'm also new to programming on the mac and working with sockets. Probably not the best first time project maybe, but I've started now! So I wish to continue :) Any help would be nice!

Thank you in advance!
