This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / Need help for a small C program
-secfan(WhoAmI?);
2007-9-18
{1178}
(#3938888@0)
-
Normally the receive function ( recv() or something like that) has a parameter to indicator the timer. You can check the return value of the function to determine it is timed out or not.
-exception(违例);
2007-9-18
(#3939211@0)
-
Google SIGALRM. Use alarm() to start a timer. Use signal() to install a function to run when SIGALRM is received.
-dusk(~小桥流水~);
2007-9-18
(#3939247@0)
-
believe you need introduce multi-threadmy opinion:
get a timer thread and the existing sender/receiver thread
set a mutual parameter accessible for both threads indicating the receiving status
everytime after sending a packet, start timer thread, timer thread sleeps for 2 sec
after sleeping, check the receiving status parameter
in sender/receiver thread, after sending a packet, open socket waiting for response, if got any, set parameter to received status, kill time thread, send next
-james_sep(James);
2007-9-18
{455}
(#3939933@0)
-
Using TCP/IP socket or not? On Unix & linux? SIGALRM is for posix threads?
-foolzz(foolzz);
2007-9-18
(#3940032@0)
-
既然是作业, 应该交代用TCP还是UDP. TCP简单些, 连起来听两分钟就行了. 我个人猜测, 恐怕是让你们用UDP, 发i am alive, are you alive之类的信号. timer一定要multithreaded.
-piglet(迪斯尼fan);
2007-9-18
(#3940228@0)
-
Ask your TA/Prof, they will provide help, ask somewhere else does not really help you as much as they do.
-canadiantire(轮胎-El Caro);
2007-9-19
(#3941172@0)
-
Thanks for the suggestion. TA and prof won't help me in writing the code. I don't have any problem understanding the networking theory. I just don't have time to pick up C programming from beginning.
-secfan(WhoAmI?);
2007-9-19
(#3941192@0)