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)
If RN=x is received from B, and x=i+1, set SN=i+1.
(RN is label for packet coming back from B)
If timer expires, resend pkt SN=i
Description of B:
Send out packet with RN = j
If SN=y is received from A, and y=i, set RN=i+1.
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.