C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-05-2009, 08:33 PM   #1
Registered User
 
Join Date: Dec 2009
Posts: 1
C Programming: give command a 5 sec interval to run

Hi all,

I am new to C and I need some help solving an issue with network programming.
So in general, i have two programs running: Program A and Program B.

Description of A:
Send out packet with SN = i
(SN is the label for the packet. i.e first pkt SN=1, 2nd pkt SN=2 etc)
Set timer
If RN=x is received from B, and x=i+1, set SN=i+1.
(RN is label for packet coming back from B)
Otherwise, ignore.

If timer expires, resend pkt SN=i
Reset timer
and repeat.

Description of B:
Send out packet with RN = j
Set timer
If SN=y is received from A, and y=i, set RN=i+1.
Otherwise, ignore.
repeat

In short, these two programs are just loops. A needs to receive an acknowledgment from B to proceed to the next state, otherwise resend the current packet. And for B, if B received a packet from A, it will send an acknowledgment to A telling it to move on to next state.

My problem is with the "Set timer" part. So this part is supposed to allow about 5 seconds for each program to receive pkt. For those who know how to use the select() function, I want something similar select() except it will watch over an integer (like SN and RN) instead of just a socket.

Thanks in advance.
kcirtap is offline   Reply With Quote
Old 12-05-2009, 10:24 PM   #2
Registered User
 
Join Date: Sep 2006
Posts: 3,720
You could use sleep(number of seconds), or Sleep(ditto). One or the other should be available on your system
Adak is offline   Reply With Quote
Old 12-06-2009, 04:33 AM   #3
Registered User
 
Join Date: Dec 2009
Posts: 1
Hi!!
Only option is sleep as mentioned by "Adak".
I never done in C language but used in JAVA programming.
I don't have idea about the sleep function of C.
Sorry for that but yes you JAVA provides this function and I did the mentioned hand shake program.
BruceSmith is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sort a simple linked list using swap-sort method JOCAAN C Programming 26 07-05-2010 10:43 AM
folllowing code should call the copy constructor and shud not give run time error! Alexpo C++ Programming 3 11-16-2009 07:51 AM
Dev C++: can't run code blurrymadness C++ Programming 0 08-07-2009 07:33 PM
triggering another program to run using serial port infineonintern C++ Programming 3 07-22-2009 05:16 AM
implementing to set time interval to allow program to run on its own?? matrix_ying C Programming 2 02-28-2002 12:40 PM


All times are GMT -6. The time now is 12:05 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22