本文发表在 rolia.net 枫下论坛I'm taking a networking course. One assignment is about modifying an existing C program to handle network communication differently. It might be a breeze for all C programmers. But for me, who learned C language almost 18 years ago and have never done any C programming since then, it is a big challenge. Could someone give me a hand?
The existing program simulates the communication between two machines over the network. There is a sender program which sends data and waits for response from the receiver, and then decides whether to continue sending next unit of data or resend the last unit based on the response it receives from the receiver. This continues until all data is transmitted.
The assignment is to introduce a SIGALRM function in the sender program and set the timer to 2 seconds. If the sender gets a response within two seconds from the receiver, turn off the alarm and transmit the next unit of data. If no response is received, time out function kicks in and retransmits the last unit of data.
I have no idea about how to use SIGALRM function and how to set timer. I tried to google it out but still don't get it. Any help is greatly appreciated.更多精彩文章及讨论,请光临枫下论坛 rolia.net
The existing program simulates the communication between two machines over the network. There is a sender program which sends data and waits for response from the receiver, and then decides whether to continue sending next unit of data or resend the last unit based on the response it receives from the receiver. This continues until all data is transmitted.
The assignment is to introduce a SIGALRM function in the sender program and set the timer to 2 seconds. If the sender gets a response within two seconds from the receiver, turn off the alarm and transmit the next unit of data. If no response is received, time out function kicks in and retransmits the last unit of data.
I have no idea about how to use SIGALRM function and how to set timer. I tried to google it out but still don't get it. Any help is greatly appreciated.更多精彩文章及讨论,请光临枫下论坛 rolia.net