That's not the "every 10 seconds" called for.
How do you expect the heartbeat process to act? If the heartbeat arrives before 9.9999999999999999999999999999 seconds or after 10.00000000000000000000000001 seconds, the other end is considered dead?
Typical heartbeat implementation need to get a heartbeat within a certain timeout.
See it? The source/destination pairs are the same in both directions (Ie. for the client to server heartbeats and the server to client transfers) which makes the question of whether two local processes can use the same local port concurrently very relevant!
Sure, if you assume the server and client are the same machine. As I understand, there are 8 one-way connections:
- client:53036 to server:8020
- client:53037 to server:8019
- client:53038 to server:8008
- client:53039 to server:8003
- server:8020 to client:53036
- server:8019 to client:53037
- server:8008 to client:53038
- server:8003 to client:53039
I fail to see why that leads to two processes using the same port.
And if these are two separate processes, how will the heartbeat process know when the read process is between reads?
Why should it have to know? It's just a heartbeat. The OP didn't state such a requirement, so why should I assume one?
Use short reads with UDP and data gets thrown way.
With short reads, I mean, "don't keep reading packets until there's nothing waiting before checking the time again". I'm not assuming the OP manages to create UDP packets that are so big, it takes more than 10 seconds to read one packet.
You made two suggestions in that post, the second of which used multiple processes, with separate processes for the heartbeats and data transfers.
I wouldn't describe my second suggestion a sketch. But anyway, that suggestion uses 8 processes, each focussing on one port, all different.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||