PTC MKS Toolkit Knowledge Base

Section:IO
Product:MKS Toolkit (TKPDev/TKEDev)
Version:
OS:All
Keywords:porting, binary data
Category:Porting/Knowledge Base


Why does my MKS Toolkit ported application read my binary data files incorrectly?


You could have a byte-ordering problem. The MKS Toolkit Resource Kit contains a port of ONC RPC, including XDR. The XDR functions (and the program RPCGEN) help you encode and decode binary data. The resource kit contains a sample use of XDR to save/retrieve a data structure in a platform neutral form, using the xdrstdio library. Libraries exist for UDP, TCP, memory, and the file system.

The MKS Toolkit socket library has implementations of htons(), htonl(), ntohs(), and ntohl(). Where XDR is overkill, you can use these functions to encode and decode 16- and 32-bit integers.