Solved

I'm looking to find a way to receive a UDP packet via interrupts vs. some form of polling in C.  I am trying to minimize CPU resources as much as possible.  Thanks!

Posted on 2009-04-04
1
283 Views
Last Modified: 2013-11-29
I'm looking to find a way to receive a UDP packet via interrupts vs. some form of polling in C.  I am trying to minimize CPU resources as much as possible.  Thanks!
0
Comment
Question by:rounders1086
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 500 total points
ID: 24068148
1) select() with reasonable timeout value is a great, simple way to poll while not blocking indefinitely. select() for 100 milliseconds at a time lets your loop process 10 times a second if needed. If a packet arrives, the select will return immediately without waiting for 100ms.

2) A thread that just issues a blocking read()/recvfrom() is probably as cpu minimal as you can get.

Are you only interested in processes the packet, or are there other tasks that must be carried out in parallel? If so, either option above will work, but if you want to completely decouple the tasking so a long-running background task does not block the network messaging, go with a thread.

There are a few other ways, like async io receiving SIGIO to your process, then you still have to call select() to find which descriptor is ready. I prefer alternatives above to that.

If these aren't satisfactory there are other ways, including Linux non-portable ways.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Losing network connectivity 8 116
extend vlan through a layer 3 connection 31 183
awk file 6 99
policy based routing with recursive added - Cisco 1 62
A few months ago I attended the Rocky Mountain IPv6 Summit which was a two-day educational event; it was the 3rd annual conference held here in Denver, Colorado that was held at the Hyatt Regency Denver at the Colorado Convention Center. It was an e…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question