Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Keeping an INET socket inside a shared object

by BrowserUk (Patriarch)
on Jan 18, 2014 at 18:50 UTC ( [id://1071130]=note: print w/replies, xml ) Need Help??


in reply to Re: Keeping an INET socket inside a shared object
in thread Keeping an INET socket inside a shared object

I've not the foggiest idea what serially bi-directional could mean. AFAIK ...

Try it.

  1. Connect a socket to a server that attaches, and then tries to read from the client.
  2. Start a thread (in the client) that goes in to a read state on that handle.
  3. Then try to write something to the server via that handle from the main thread.

The write will block indefinitely pending the completion of the read in the thread, which will never occur because the server won't send anything.


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.
  • Comment on Re^2: Keeping an INET socket inside a shared object

Replies are listed 'Best First'.
Re^3: Keeping an INET socket inside a shared object
by oiskuu (Hermit) on Jan 18, 2014 at 19:04 UTC

    That's the blocking mechanism, and it's not limited to just sockets either. Multiple writes may block each other similarily. Set your fd nonblocking if this is a problem...

      Set your fd nonblocking if this is a problem...

      And how do you think non-blocking works with threads?

      What happens if 2 threads issue a select against the same thread and a state transition occurs -- ie. the socket becomes readable or writable -- which thread responds? Answer: they both do.

      And what happens when they both try to read from or write to the same socket at the same time?

      In a single threaded app, a socket is only readable or only writable at any given moment. Being single-threaded means that the code can only ever try to do one thing or another at a time. Ie. serially bi-directional.

      In single threaded apps it doesn't matter. In multi-threaded apps it does.


      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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found