Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: UDP connection

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


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

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?

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

        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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-03-29 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found