- {
- signal(SIGINT, HandleSIG); // SIGINT is what you get for a Ctrl-C
- signal(SIGTERM, HandleSIG);
-
- while (!StopNow)
- {
- int nfds = 0;
- fd_set readfds;
- struct timeval timeout;
- int result;
-
- // 1. Set up the fd_set as usual here.
- // 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);
-
- // 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_usec = 0;
-
- // 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout
- mDNSPosixGetFDSet(m, &nfds, &readfds, &timeout);
-
- // 4. Call select as normal
- verbosedebugf("select(%d, %d.%06d)", nfds, timeout.tv_sec, timeout.tv_usec);
- result = select(nfds, &readfds, NULL, NULL, &timeout);
-
- if (result < 0)
- {
- verbosedebugf("select() returned %d errno %d", result, errno);
- if (errno != EINTR) StopNow = mDNStrue;
- }
- else
- {
- // 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work
- mDNSPosixProcessFDSet(m, &readfds);
-
- // 6. This example client has no other work it needs to be doing,
- // but a real client would do its work here
- // ... (do work) ...
- }
- }
-
- debugf("Exiting");
- }
+{
+ signal(SIGINT, HandleSIG); // SIGINT is what you get for a Ctrl-C
+ signal(SIGTERM, HandleSIG);
+
+ while (!StopNow)
+ {
+ int nfds = 0;
+ fd_set readfds;
+ fd_set writefds;
+ struct timeval timeout;
+ int result;
+
+ // 1. Set up the fd_set as usual here.
+ // 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 = FutureTime;
+ timeout.tv_usec = 0;
+
+ // 3. Give the mDNSPosix layer a chance to add its information to the fd_set and timeout
+ mDNSPosixGetFDSet(m, &nfds, &readfds, &writefds, &timeout);
+
+ // 4. Call select as normal
+ verbosedebugf("select(%d, %d.%06d)", nfds, timeout.tv_sec, timeout.tv_usec);
+ result = select(nfds, &readfds, &writefds, NULL, &timeout);
+
+ if (result < 0)
+ {
+ verbosedebugf("select() returned %d errno %d", result, errno);
+ if (errno != EINTR) StopNow = mDNStrue;
+ }
+ else
+ {
+ // 5. Call mDNSPosixProcessFDSet to let the mDNSPosix layer do its work
+ mDNSPosixProcessFDSet(m, &readfds, &writefds);
+
+ // 6. This example client has no other work it needs to be doing,
+ // but a real client would do its work here
+ // ... (do work) ...
+ }
+ }
+
+ debugf("Exiting");
+}