- result = DNSServiceRegistrationCreate_rpc(serverPort, clientPort, (char *)name, (char *)regtype, (char *)domain, port, (char *)txtRecord);
+ // older versions of this code passed the port via mach IPC as an int.
+ // we continue to pass it as 4 bytes to maintain binary compatibility,
+ // but now ensure that the network byte order is preserved by using a struct
+ IpPort.bytes[0] = 0;
+ IpPort.bytes[1] = 0;
+ IpPort.bytes[2] = portptr[0];
+ IpPort.bytes[3] = portptr[1];
+
+ result = DNSServiceRegistrationCreate_rpc(serverPort, clientPort, (char *)name, (char *)regtype, (char *)domain, IpPort, (char *)txtRecord);