I am doing networking programming in C\C++ and the assignment asks me to send a formatted message.
The format is below:
bits: 0.....15 16....31
update# port#
Sever-IP
As you seen first line ask me to:
Convert int into 16 bits so 2 ints make up 32 bits.
Convert xxx.xxx.xxx.xxx into 32 bits.
I am using UDP, so I need get these info into a char[], and that is the hard part. In my program, I have the update# and port # as int, and server IP address as a string. How could I convert them into these bits?
Here is what I have tried:
Casting them into char. But, I need get one int into two char.
Convert them into a string, and then string.c_str(), but it gives me a 4 bytes pointer.