LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 04-29-2003, 04:24 AM   #1
harpal
LQ Newbie
 
Registered: Apr 2003
Posts: 3

Rep: Reputation: 0
how to call function??


i have a txt file of ipv6 addresses. I'm trying to code a function that will maintain these address. the structure of the file is as below

anycast_address timer unicast_address

it needs to automaticlly invoke by itself or somehow every 15 mins(to check if timer has hit 0)

i put this function along with other function in a .h file. As the fucntion will be a infinite loop function(always check the every 15 mins) I dont know where or how to call it? I need to call once and only once ......anybody can help??
 
Old 04-29-2003, 05:45 AM   #2
yrraja
Member
 
Registered: Sep 2002
Distribution: RH, FC, Ubuntu, Solaris, AIX
Posts: 114

Rep: Reputation: 15
If you know anything about signal handling in Linux, then you can use SIGALRM signal for this task. You can set the alarm to be generated every 15minutes and this signal will invote you function.

Second option would be to launch a saperate thread in which you launch this function whcih sleeps for 15minutes and then wakeup and performs the task and then goes back to sleep for 15 minutes.

Yaser
 
Old 04-29-2003, 06:46 AM   #3
harpal
LQ Newbie
 
Registered: Apr 2003
Posts: 3

Original Poster
Rep: Reputation: 0
do you have an example or know where i can find one.....
thanks...
 
Old 04-29-2003, 06:59 AM   #4
yrraja
Member
 
Registered: Sep 2002
Distribution: RH, FC, Ubuntu, Solaris, AIX
Posts: 114

Rep: Reputation: 15
If you have "Unix Network Programming" by Richard Stevens then you can look it up to see how to install a signal, and how to set the timer values for the SIGALRM signal.

For threads just search for 'Posix Thread Tutorial' in google and you will get load of tutorials telling with example code how to do it. One of the tutorials is at this link

http://dis.cs.umass.edu/~wagner/thre.../tutorial.html

If the purpose of your function is only to check the timer value and set some flag based on its value then i would recomment using SIGALRM. Otherwise go for threads.

Yaser
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call another function from a function? geminigal Programming 4 04-21-2005 11:41 PM
Call to undefined function domxml_open_mem() apt Programming 2 04-01-2005 04:25 AM
access() function call does not work rafiqul Linux - Newbie 1 01-26-2005 03:28 PM
No Matching Function for Call ! vipinsharma Programming 2 07-05-2004 02:58 PM
how to call a c++ member function from _init()? cybercop12us Programming 2 01-16-2003 07:56 AM


All times are GMT -5. The time now is 11:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration