Good evening everyone.
I’m having trouble creating a TFTP client for an assignment in C++ that uses #include
I’m sending the char buffer:
buffer={‘0′,’2′,’f’,’i’,’l’,’e’,’n’,’a’,’m’,’e’,’0′,’o’,’c’,’t’,’e’,’t’,’0′};
Using the code:
sendto(sock,buffer,strlen(buffer), 0, (sockaddr *) &serverAddr, sizeof(sockaddr));
But when I look at this transfer in the WireShark it says “Opcode: Unknown (12338)” when I look at the Opcode portion of the packet.
Even though it has selected the opcode from the string

I’m absolutely stuck, any help would be appreciated. I’m pretty sure if I can send and receive a message I can handle the rest pretty easily.
Just throwing down here what I did but the marked answer was basically it
Used the BYTE from winsock2 (don’t know if I need to but better safe than sorry)
buffer={(BYTE)0,(BYTE)2,’f’,’i’,’l’,’e’,’n’,’a’,’m’,’e’,(BYTE)0,’o’,’c’,’t’,’e’,’t’,(BYTE)0};
and
sendto(sock,buffer,sizeof(buffer), 0, (sockaddr *) &serverAddr, sizeof(sockaddr));
Not
strlen(buffer)butsizeof(buffer)…strlen stops couting characters at the first occurrence of
'\0'– so it returns unspecified value for your buffer array since'\0'is not present in your buffer.If you want to start your buffer with opcode
02then pass it as integers not their digit representation: