Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to do simultaneous reads and writes to/from a socket?

by merlyn (Sage)
on May 10, 2006 at 13:05 UTC ( #548446=note: print w/replies, xml ) Need Help??


in reply to How to do simultaneous reads and writes to/from a socket?

Rather than ithreads, consider an event system like POE. You can attach events to "line ready to read", and when the event triggers, you're the only one running so you can access your shared data easily without having to "lock" or "block".

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re: How to do simultaneous reads and writes to/from a socket?

Replies are listed 'Best First'.
Re^2: How to do simultaneous reads and writes to/from a socket?
by sonofason (Sexton) on May 10, 2006 at 14:00 UTC

    jesuashok: Perhaps I should have mentioned earlier that I am working under Windows. Apparently, doing non-blocking socket IO under Windows is a little problematic, as discussed here. The polling solution does work well though and hopefully won't consume too much resources if I sleep for a short time (since I want to act immediately on incoming data) in between polls.

    merlyn: I will take a look at POE and see how it can help me.

    MonkE: I do understand that much more is needed for the server, but the code I posted was just a simplified exerpt from the client program. Thanks though!

    Many thanks!
    sonofason

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548446]
help
Chatterbox?
[Lady_Aleena]: And the env variable $HOME doesn't work either. !@#$
[shmem]: no, that's a shell feature. Use $ENV{HOME}
[marioroy]: my $ans = qx{ find \$HOME -name "*.pl" -exec ls -l {} \\; };
[marioroy]: must backslash $ inside qx
[Lady_Aleena]: I haven't written perl for a while, I've been trying to do things at the command line. I'm having to relearn a lot.
[marioroy]: LA can you post the qx find again
[Lady_Aleena]: Things I would have written a script for while I was on Windows, I can run simply on the command line.
[Lady_Aleena]: marioroy, my @music_times = qx(find ~/Music/Albums/ -type f -iname '*.mp3' -exec mp3info -p "%S\n" {} \;); #unfixed
shmem doesn't have mp3info, but mp3info2 - which is a perl script ;-)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-04-23 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.