Help for this page

Select Code to Download


  1. or download this
    std::string Request("abcdefghijklmnopq"); // just an example, for test
    +ing
    uint32_t msgLen = Request.length();       // msgLen = 17 for this test
    + case
    msgLen = htonl(msgLen); // convert to network ordered long int
    Socket().Write( reinterpret_cast< char * >(&msgLen), sizeof(msgLen));
    
  2. or download this
    Socket().Write( Request.begin(), Request.length() );
    
  3. or download this
    Socket().Read(&msgLen, sizeof(msgLen));
    msgLen = ntohl(msgLen); // convert back from network ordered long int
    Socket().Read(&buffer, msgLen); // read response into buffer
    
  4. or download this
    char msg2[256];
    memset(msg2,0,256);
    ...
    Socket().Read(msg2, nlen); // read the request
    log.Printf("Request: %s", msg2);
    
  5. or download this
    New client connection accepted
    1. msg2: 0000 0000 0000 0011
    ...
    Request: abcdefghijklmnopq
    Response: hello world
    Closing connection.
    
  6. or download this
    New client connection accepted
    msg2: 0032 0038 0035 0032
    ...
    msg2: 50 56 53 50
    before ntohl: nlen = 842348594 (hex: 32353832)
    after ntohl: nlen = 842544434 (hex: 32383532)
    
  7. or download this
    #!/usr/bin/perl
    use strict;
    ...
      return $output;
    }