#include <errno.h> // For errno, EINTR
#include <signal.h>
#include <fcntl.h>
+#include <sys/socket.h>
#if __APPLE__
#undef daemon
#pragma mark ***** Globals
#endif
-static mDNS mDNSStorage; // mDNS core uses this to store its globals
+mDNS mDNSStorage; // mDNS core uses this to store its globals
static mDNS_PlatformSupport PlatformStorage; // Stores this platform's globals
mDNSexport const char ProgramName[] = "mDNSResponderPosix";
domainname domain;
status = mStatus_NoError;
- thisServ = (PosixService *) malloc(sizeof(*thisServ));
+ thisServ = (PosixService *) calloc(sizeof(*thisServ), 1);
if (thisServ == NULL) {
status = mStatus_NoMemoryErr;
}
status = mDNS_RegisterService(&mDNSStorage, &thisServ->coreServ,
&name, &type, &domain, // Name, type, domain
NULL, mDNSOpaque16fromIntVal(portNumber),
- text, textLen, // TXT data, length
+ NULL, text, textLen, // TXT data, length
NULL, 0, // Subtypes
mDNSInterface_Any, // Interface ID
RegistrationCallback, thisServ, 0); // Callback, context, flags
static void DeregisterOurServices(void)
{
PosixService *thisServ;
- int thisServID;
while (gServiceList != NULL) {
thisServ = gServiceList;
gServiceList = thisServ->next;
- thisServID = thisServ->serviceID;
-
mDNS_DeregisterService(&mDNSStorage, &thisServ->coreServ);
if (gMDNSPlatformPosixVerboseLevel > 0) {
while (!gStopNow)
{
int nfds = 0;
- fd_set readfds;
+ fd_set readfds, writefds;
struct timeval timeout;
int result;
// This example client has no file descriptors of its own,
// but a real application would call FD_SET to add them to the set here
FD_ZERO(&readfds);
+ FD_ZERO(&writefds);
// 2. Set up the timeout.
// This example client has no other work it needs to be doing,
// so we set an effectively infinite timeout
- timeout.tv_sec = 0x3FFFFFFF;
+ timeout.tv_sec = FutureTime;
timeout.tv_usec = 0;
// 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout
- mDNSPosixGetFDSet(&mDNSStorage, &nfds, &readfds, &timeout);
+ mDNSPosixGetFDSet(&mDNSStorage, &nfds, &readfds, &writefds, &timeout);
// 4. Call select as normal
verbosedebugf("select(%d, %d.%06d)", nfds, timeout.tv_sec, timeout.tv_usec);
else
{
// 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work
- mDNSPosixProcessFDSet(&mDNSStorage, &readfds);
+ mDNSPosixProcessFDSet(&mDNSStorage, &readfds, &writefds);
// 6. This example client has no other work it needs to be doing,
// but a real client would do its work here