Hi
I am doing a simple client implementation of TFTP. Here i need to send read request in following format
/* send request
2 bytes string 1 byte string 1 byte
------------------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -------------------------------------------------
*/
in between i have to insert 1 byte zero bits value . But i am not able to add that value. Also if i add a 1 zero bits byte.. which actually means a string terminating character than how to get proper strlen value.
If any one can help me with this...
enter code here
const char opcode_read[2] ={'0','1'};
const char opcode_write[2] ={'0','2'};
const char opcode_data[2] ={'0','3'};
const char opcode_acknowledge[2] ={'0','4'};
const char opcode_error[2] ={'0','5'};
const char mode_netascii[] = "netascii\0";
char blk_read_request[100];
char file_name[] = "rfc0791.txt\0";
memcpy(blk_read_request, opcode_read, 2);
memcpy(&blk_read_request[2], file_name, strlen(file_name) + 1);
memcpy(&blk_read_request[2 + strlen(file_name)], mode_netascii, strlen(mode_netascii) + 1);
for (int i = 0; i < strlen(blk_read_request); i++) {
cout << i << " : " << blk_read_request[i] << " " << std::bitset<CHAR_BIT > (blk_read_request[i]) << "\n";
}