Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: UDP connection

by JavaFan (Canon)
on May 03, 2012 at 21:26 UTC ( #968816=note: print w/ replies, xml ) Need Help??


in reply to Re^4: UDP connection
in thread UDP connection

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:
  1. client:53036 to server:8020
  2. client:53037 to server:8019
  3. client:53038 to server:8008
  4. client:53039 to server:8003
  5. server:8020 to client:53036
  6. server:8019 to client:53037
  7. server:8008 to client:53038
  8. 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.


Comment on Re^5: UDP connection
Re^6: UDP connection
by BrowserUk (Pope) on May 03, 2012 at 22:26 UTC
    How do you expect the heartbeat process to act?

    It wasn't clear from the OPs description, so I asked.

    Sure, if you assume the server and client are the same machine.

    I made no such assumption.

    As I understand, there are 8 one-way connections:

    Can you not see, from your own posting, that there are four pairs of ports, and each pair has to communicate in both directions?

    . The OP didn't state such a requirement, so why should I assume one?

    It is implied by the OPs description. Why would you assume the opposite?

    I didn't assume; I asked.

    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.

    The OP isn't creating them. The pre-existing server might be,

    And I didn't assume it; I asked.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Can you not see, from your own posting, that there are four pairs of ports, and each pair has to communicate in both directions?
      No.

      I've listed the 8 data streams I've seen described by the OP. They use ports 8020, 8019, 8008, 8003 to send from, and ports 53036, 53037, 53038, 53039 to listen to. I haven't seen the OP describe traffic originating from ports 53036, 53037, 53038, 53039.

      But whether or not there's bidirectional UPD traffic, that's irrelevant. I still don't see 2 processes trying to use the same port. Can you point out a port, and the two processes that need to access it?

      It is implied by the OPs description.
      Why?
      The pre-existing server might be,
      Most services restrict UDP packets to be at most 512 bytes. But even if they don't, UDP packets are restricted to be at most 65535 bytes (as the length field of the header is 2 bytes large), leaving slightly less for the payload. I just haven't assumed the OP runs hardware that needs more than 10 seconds to copy 65535 bytes from the IP stack to the process' memory.
        I haven't seen the OP describe traffic originating from ports 53036, 53037, 53038, 53039.

        Geez Louise. Re-read the OPs post but concentrate on a single pair of ports:

        1. The server listens on 4 ports 8020 ....
        2. The client sends the first heartbeat from ports: 53036, ... to ports 8020, ..., This repeats in every 10 seconds.
        3. When server ... [it] replies from ports 8020, ... to ports 53036, ....
        4. If ... the server ... sends them to ports 53036, ....

        Graphically:

        step | Action | Server | direction | client -----+--------+--------+-----------+------- 1 | Listen | 8020 | | -----+--------+--------+-----------+------- 2 | h'beat | 8020 | <-------- | 53036 Client 53036 originates; S +erver 8020 receives. -----+--------+--------+-----------+------- 3 | resp | 8020 | --------> | 53036 Server 8020 originates; cl +ient 53036 receives. -----+--------+--------+-----------+------- 4 | data | 8020 | --------> | 53036 Server 8020 originates; cl +ient 53036 receives. -----+--------+--------+-----------+-------

        4 ports at the server, 4 ports at the client; 4 bi-directional conversations. There is no ambiguity.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968816]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-09-21 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls