Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6818965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:14:31+00:00 2026-05-26T21:14:31+00:00

I have a multicast receive daemon that is running as a NSThread. While it’s

  • 0

I have a multicast receive daemon that is running as a NSThread. While it’s waiting to receive, I’d like to be able to cancel it without waiting for another packet which may not come. Since it’s just waiting, I can’t execute other code to check isCancelled. How can I do this?

Here’s the code that is receiving.. It sits and waits on the first line until a packet comes in.

/* block waiting to receive a packet */
            if ((recv_len = recvfrom(sock, recv_str, MAX_LEN, 0,
                                     (struct sockaddr*)&from_addr, &from_len)) < 0) {
                [delegate multicastDaemonDidFinish:self withError:@"recvfrom() failed"];

                exit(1);
            }
            receivedString = [NSString stringWithFormat:@"%s", recv_str];
            [delegate multicastDaemonDidReceiveData:self receivedString:receivedString];

In the parent, who is also the delegate, this Thread is called by:

    [daemonThread initWithTarget:multicastDaemon selector:@selector(doWorkWithDelegate:) object:self];
    [daemonThread start];

I can issue a [daemonThread cancel], but daemonThread will never check isCancelled while he’s waiting. How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:14:32+00:00Added an answer on May 26, 2026 at 9:14 pm

    You could loop on a select call with a timeout. If the select returns 0, then it timed out so you have the opportunity to check on the cancel flag, and either exit the thread or perform the select again. If there is something to receive then process it with recevfrom and exit out of the loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been unable to receive UDP multicast under VxWorks 5.5. I've joined the
I have a udp client that is listening for multicast messages. When it gets
I have a custom patch for Quartz Composer that is a multicast receiver. It
I have some code that listens for announcements via UDP multicast. I can get
I have a simple C# application that uses UDP multicast in a single-receiver, single-sender
I have a C# .Net 3.5 application that sends a multicast Hello packet to
when i receive a response from the server without that is not handle by
We have a C# application that can join and receives data from a multicast
We have a publisher application that sends out data using multicast. The application is
I have proprietary application sending out multicast packet to the network. It is running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.