Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: UDP connection

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


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

If a read is in progress when the 10 seconds times out, then the heartbeat will be delayed until the read completes.
Sure, and if that's a problem, send it after 9.8 seconds, or some other interval. Read in small chuncks if that's required. Or just use a separate process.
But can two concurrent processes talk from the same local port concurrently?
Whether or not that's possible is irrelevant (however, this is UDP we're talking about, it's isn't about armies of ogres having to exit a tower through a narrow gate), as that is not what the OP seems to be doing. To quote him:
The client sends the first heartbeat from ports: 53036, 53037, 53038, 53039 to ports 8020, 8019, 8008, 8003. This repeats in every 10 seconds.
Oh, and do note that in my sketch, there's just one program anyway.


Comment on Re^3: UDP connection
Re^4: UDP connection
by BrowserUk (Pope) on May 03, 2012 at 19:52 UTC

    Oh dear, here we go again.

    1. send it after 9.8 seconds,

      1) That's not the "every 10 seconds" called for.

    2. Read in small chuncks ...

      To quote you "this is UDP we're talking about,".

      And to quote from the man page that you should probably review before giving your next knee-jerk response:

      If a message is too long to fit in the supplied buffer, excess bytes may be discarded depending on the type of socket the message is received

      Use short reads with UDP and data gets thrown way. Something the OP took pains to explain he cannot allow to happen.

    3. Or just use a separate process.

      And if these are two separate processes, how will the heartbeat process know when the read process is between reads?

    Three ideas, that it takes just a few seconds to dismiss as unworkable.

    Whether or not that's possible is irrelevant ... that is not what the OP seems to be doing. To quote him: ...

    You quote only section 2 of the OPs response to my questions.

    Selective amnesia; or did ADHD kick in before you got to section 3?

    Let's quote him a little more:

    2) The client sends the first heartbeat from ports: 53036, 53037, 53038, 53039 to ports 8020, 8019, 8008, 8003. This repeats in every 10 seconds.

    3) When server receives them replies from ports 8020, 8019, 8008, 8003 to ports 53036, 53037, 53038, 53039.

    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!

    Oh, and do note that in my sketch, there's just one program anyway.

    You made two suggestions in that post, the second of which used multiple processes, with separate processes for the heartbeats and data transfers.

    And both of which cannot possibly work for the OPs requirements as described.


    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?

      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.
        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?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2014-08-30 00:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (289 votes), past polls