Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: UDP connection

by BrowserUk (Patriarch)
on May 03, 2012 at 14:02 UTC ( [id://968743]=note: print w/replies, xml ) Need Help??


in reply to Re: UDP connection
in thread UDP connection

untested pseudo code

If a read is in progress when the 10 seconds times out, then the heartbeat will be delayed until the read completes.

much simpler solution though

Two processes will be able to send to the same remote port 'simultaneously' -- thought the tcpip stack will serialise those communications.

But can two concurrent processes talk from the same local port concurrently?

Neither scenario seems to fit the OPs exact description does it!


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?

Replies are listed 'Best First'.
Re^3: UDP connection
by JavaFan (Canon) on May 03, 2012 at 14:45 UTC
    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.

      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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found