Sponsored Content
Operating Systems Linux Socket communication and timer application Post 302203237 by tryit on Saturday 7th of June 2008 05:58:34 AM
Old 06-07-2008
Socket communication and timer application

tcp communication application
i have an application which run in

1)
while()
{in

}
and listens for some request
When a request comes to create a file(containing some data fetch from somewhere)
but i also want to start some timer that after 10/20 min delete that file
But i don't know how to create such timer

2)
Also
now i want to open listening socket (with some other application).this socket will continue listening for alarms send by that application and forward it to other application

but this should not be blocking as the alarm comes it should forward it . this should not be blocking because it will block the other portion of code until and unless it recieves alarm

I read about select . Can it be used in this scenario

It will be great if some body helps me out
 

10 More Discussions You Might Find Interesting

1. Programming

ftp application using socket programming

i have made a ftp application in socket programming which uses TCP/IP .. i have the problem runing the only problem is on the client side i take the user input for the file to be downloaded from the command promt. write(s, argv, strlen(argv)+1); // this is how i write in client side argv is... (1 Reply)
Discussion started by: toughguy2handle
1 Replies

2. UNIX for Dummies Questions & Answers

Which application has a TCP socket open

If I do a netstat -a I can see all the sockets currently open, is there a way that I can tell which application is holding open these sockets ? (3 Replies)
Discussion started by: murphyboy
3 Replies

3. Programming

socket communication but not writing

hello, when i execute my code server side it connects with the client and when i try to write through the server into the client the program exits. i could not understand whether it is the problem with the server or with the client.The Protocol is TCP/IP. thanking you. (2 Replies)
Discussion started by: madfox
2 Replies

4. Linux

segmentation fault in socket application

helo, i m using linux operationg system at both client and server side. Now in my application when i use ntohl() then it will give segmentation fault. now when i remove nothl(), then it works fine. can u tell me why this happen. amit (8 Replies)
Discussion started by: amitpansuria
8 Replies

5. UNIX for Dummies Questions & Answers

socket communication and timer application

i need to develop application which continuously wait for a request from multiple host and on receiving a request on that need to create a log file and after 30 mins delete that file I am new to socket programming so could anyone help me on this. How to continuously listen for a request How... (0 Replies)
Discussion started by: tryit
0 Replies

6. UNIX for Dummies Questions & Answers

socket programming using udp for chat application

hi, i have a source code for 1 server and 2 clients ...but the clients are not able to send data..1 server only receives data from clients and forwards to any other client, the data is in the buffer.....please help... thank you in advance..... /**********client1***************/ // Here Data... (1 Reply)
Discussion started by: unsweety
1 Replies

7. Programming

socket system call can not succedd right after application crash.

hello all, I have developed a server application in C for ulinux kernel 2.6.It works very fine; creating a socket, binding it to a port, listening for incoming sockets and accepting them ,all finish without any error. But there is a problem regarding application crash.After an intentionally... (1 Reply)
Discussion started by: Sedighzadeh
1 Replies

8. Programming

Client/Server Socket Application - Preventing Client from quitting on server crash

Problem - Linux Client/Server Socket Application: Preventing Client from quitting on server crash Hi, I am writing a Linux socket Server and Client using TCP protocol on Ubuntu 9.04 x64. I am having problem trying to implement a scenario where the client should keep running even when the... (2 Replies)
Discussion started by: varun.nagpaal
2 Replies

9. UNIX and Linux Applications

Timer application in linux

Hello everyone, It is good to be here. I am a newbie to Linux.Can anyone help me in designing a timer application. The timer has to start.And after certain time interval the program should call a function continuously.It should not be in sleep mode.During the course of that time interval the... (0 Replies)
Discussion started by: Harry443
0 Replies

10. Programming

Application with communication between process

Hello I would like to create an application with communication between processes, application tightly coupled, have you please an idea about an API or a tool that allows me to generate such application? Thank you so much (11 Replies)
Discussion started by: chercheur857
11 Replies
SNMP_ALARM(3)							     Net-SNMP							     SNMP_ALARM(3)

NAME
snmp_alarm_register, snmp_alarm_register_hr, snmp_alarm_unregister - alarm functions SYNOPSIS
#include <net-snmp/utilities.h> unsigned int snmp_alarm_register(unsigned int seconds, unsigned int flags, SNMPAlarmCallback *f_callback, void *clientarg); unsigned int snmp_alarm_register_hr(struct timeval t, unsigned int flags, SNMPAlarmCallback *f_callback, void *clientarg); void snmp_alarm_unregister(unsigned int reg); DESCRIPTION
These functions implement support for a generic timer handling mechanism for multiple parts of an application to register function call- backs to happen at a particular time in the future. USAGE
The usage is fairly simple and straight-forward: Simply create a function you want called back at some point in the future. The function definition should be similar to: void my_callback(unsigned int reg, void *clientarg); Then, call snmp_alarm_register() to register your callback to be called seconds from now. The flags field should either be SA_REPEAT or NULL. If flags is set with SA_REPEAT, then the registered callback function will be called every seconds. If flags is NULL then the func- tion will only be called once and then removed from the alarm system registration. The clientarg parameter in the registration function is used only by the client function and is stored and passed back directly to them on every call to the system. The snmp_alarm_register() function returns a unique unsigned int (which is also passed as the first argument of each callback), which can then be used to remove the callback from the queue at a later point in the future using the snmp_alarm_unregister() function. If the snmp_alarm_register() call fails it returns zero. In particular, note that it is entirely permissible for an alarm function to unregister itself. The snmp_alarm_register_hr() function is identical in operation to the snmp_alarm_register() function, but takes a struct timeval as a first parameter, and schedules the callback after the period represented by t (the letters hr stand for "high resolution"). The operation of this function is dependent on the provision of the setitimer(2) system call by the operating system. If this system call is not avail- able, the alarm will be scheduled as if snmp_alarm_register() had been called with a first argument equal to the value of the tv_sec member of t. See, however, the notes below. INITIALIZATION
The init_snmp() function initialises the snmp_alarm subsystem by calling init_snmp_alarm() and then init_alarm_post_config() to set up the first timer to initialise the callback function. These two functions should not be used directly by applications. NOTES
The default behaviour of the snmp_alarm subsystem is to request SIGALRM signals from the operating system via the alarm(2) or setitimer(2) system calls. This has the disadvantage, however, that no other part of the application can use the SIGLARM functionality (or, if some other part of the application does use the SIGALRM functionality, the snmp_alarm subsystem will not work correctly). If your application runs a select(2)-based event loop, however, there is no need to use SIGALRM for the snmp_alarm subsystem, leaving it available for other parts of the application. This is done by making the following call: netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_ALARM_DONT_USE_SIG, 1); before calling init_snmp(). Then, snmp_select_info() takes alarms into account when calculating the timeout value to be used for select(2). All you need to do is call run_alarms() when select(2) times out (return value of zero). This is the approach taken in the agent; see snmpd.c. Furthermore, when using this method, high resolution alarms do not depend on the presence of the setitimer(2) system call, although overall precision is of course still determined by the underlying operating system. Recommended. SEE ALSO
netsnmp_session_api(3), default_store(3), alarm(2), setitimer(2), select(2) V5.7.2 01 Aug 2002 SNMP_ALARM(3)
All times are GMT -4. The time now is 10:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy