in reply to Can I/O operations on the same IO::Socket be executed in different threads?

Excellent thread you refer-to ... everyone should read it carefully all the way through.   (I just tossed-out a bunch of up-votes.)

There is one classic design for working with multiple sockets: a select-loop, which polls a list of sockets to find out which one(s) have data, managed by one thread, which acts as the incoming and outgoing gatekeeper for the entire system.   This design works extremely well, and there are plenty of CPAN modules out there which already implement all of it.

Network I/O is a comparatively slow operation, so there is plenty of time, even with many sockets to tend.   But there’s also one other important consideration:   the need to track the state of the external systems with which you are communicating.   If a single thread is pulling off a sequential stream of messages from multiple sockets, there will never be any timing issues.   That one thread, with simple FSM = Finite-State Machine logic, can keep track of them all, and can do whatever protocol exchanges are needed.   Meanwhile, the worker threads, who are listening and writing to thread-safe queues populated by the gatekeeper, need have no such concerns.

Replies are listed 'Best First'.
Re^2: Can I/O operations on the same IO::Socket be executed in different threads?
by eyepopslikeamosquito (Archbishop) on May 12, 2015 at 12:44 UTC

    Excellent thread you refer-to ... just tossed-out a bunch of up-votes
    You are responding to the root node. The root node does not refer to any PM thread. Nothing to up-vote.

    Once again you are replying to the wrong post. Did you mean to reply to BrowserUk's response?

      Yes, I did up-vote (yes, I said up...) BrowserUK’s comments to this thread and to the other thread that he referred-to ... while also (intending to be) speaking very favorably of it.   I also up-voted several other comments including later ones in the that same thread (near the end of it).

Re^2: Can I/O operations on the same IO::Socket be executed in different threads?
by BrowserUk (Patriarch) on May 12, 2015 at 12:15 UTC

    Don't you ever tire of making a fool of yourself? More of your trade mark utter garbage!


    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". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked