Thread: Sending non-(char*) data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    He's trying.
    Join Date
    Apr 2005
    Location
    Missouri, US
    Posts
    70
    When I sent the int to myself, yes, I did serialize it with htonl & ntohl, and yes, I now see why sending an std::string was so silly...and I do know about .c_str(), I just wanted to see if I could send it.

    Btw - wasn't talking about just sending a structure, I thought putting the two ints it was comprised of into network byte-order (that's big-endian, right?) and then sending the structure might work, provided the same structure was on the other end?

    As for casting my int in network byte-order as char* (because that's all the function would accept), it did work...I don't see why it shouldn't, as long as when I receive the data on the other end I cast it back to int and put it in host byte-order, right?

    Read some of the C++ FAQ Lite and found some other things on putting non-integers into byte order with unions.
    Last edited by Nazca; 07-31-2005 at 12:55 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. sending n no of char data uning send() function,
    By thebrighter in forum Windows Programming
    Replies: 1
    Last Post: 08-22-2007, 12:26 PM
  3. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  4. Replies: 1
    Last Post: 02-06-2003, 03:33 PM
  5. sending data to printer port
    By lliero in forum C Programming
    Replies: 3
    Last Post: 11-20-2001, 04:57 AM