Target address reversed
<p>I use to code in Python. Now I'm trying C++. When I run the program I see the target address (w/ Wireshark) reverse, even if I use htonl. In Python this same program worked fine.
Follow the code. At the bottom I printed the result.
I'm using Ubuntu 12.04LTS and g++ (Ubuntu/Linaro 4.6.3).</p>

<pre><code>//UdpClient.cpp
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;sstream&gt;
#include &lt;sys/socket.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;netdb.h&gt;
#include &lt;cstdlib&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;typeinfo&gt;
using namespace std;

int main(int argc, char* argv[])
{
    int s, p, rb,rs;
    int bytesend;
    char buf[1024];
    int len;
    char ent[16];
    char Porta[5];
    unsigned long EndServ;
    struct sockaddr_in UdpServer, UdpClient;
    int UdpServerLen = sizeof(UdpServer);
    //do text
    string msg("The quick brown fox jumps over the lazy dog\n");
    len = msg.copy(buf, msg.size(), 0);

    buf[len] = '\0';
    //do socket
    s = socket(AF_INET, SOCK_DGRAM, 0);
    if (s == -1){
        cout &lt;&lt; "No socket done\n";
    }
    else {
        cout &lt;&lt; "Socket done\n";
    }
    //populate UdpClient struct
    UdpClient.sin_family = AF_INET;
    UdpClient.sin_addr.s_addr = INADDR_ANY;
    UdpClient.sin_port = 0;
    //populate UdpServer struct
    UdpServer.sin_family = AF_INET;
    UdpServer.sin_addr.s_addr = inet_addr(argv[1]);
    //check if addres is correct
    cout &lt;&lt; "ServerAddress: " &lt;&lt; hex &lt;&lt; UdpServer.sin_addr.s_addr &lt;&lt; endl;
    UdpServer.sin_port = htons(atoi(argv[2]));
    //bind socket
    rb = bind(s, (struct sockaddr *)&amp;UdpClient, sizeof(UdpClient));
    if (rb == 0){
        cout &lt;&lt; "Bind OK!\n";
    }
    else {
        cout &lt;&lt; "Bind NOK!!!\n";
        close(s);
        exit(1);
    }
    //send text to Server
    cout &lt;&lt; "UdpServSiz: " &lt;&lt; sizeof(UdpServer) &lt;&lt; endl;
    rs = sendto(s, buf, 1024, 0, (struct sockaddr *)&amp;UdpServer, sizeof(UdpServer));
    if (rs == -1){
        cout &lt;&lt; "Message NOT sent!!!\n";
    }
    else {
        cout &lt;&lt; "Message SENT!!!\n";
    }
    close(s);
    return 0;
}
/*
  edison@edison-AO532h:~/CmmPGMs$ ./UdpClient 127.0.0.1 6789
  Socket done
  ServerAddress: 100007f (using htonl or not!!)
  Bind OK!
  Message SENT!!!
  edison@edison-AO532h:~/CmmPGMs$ 
*/
</code></pre>
