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

Re^2: How to introduce threading in socket communication

by BrowserUk (Pope)
on Oct 13, 2013 at 17:11 UTC ( #1058086=note: print w/replies, xml ) Need Help??

in reply to Re: How to introduce threading in socket communication
in thread How to introduce threading in socket communication

# sub server_thread { print "[Server]\n"; use IO::Socket; use IO::Select; use strict; my $server = IO::Socket::INET::->new(Proto => 'tcp', LocalPort => 55555, Listen => 1, Reuse => 1 ) or die "Server can't start +: $!"; my $readable_handles = new IO::Select(); ... # It is an ordinary client socket, ready for reading. $buf = <$sock>; ...

Using buffered IO reads with an IO::Select server is fundamentally flawed. If any one client sends a packet that doesn't contain the right delimiter -- whether through programmer error; or because the user aborts the client mid-transmission; or because tcp decides to fragment the packet at an inappropriate point -- then your server will hang indefinitely.

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2016-10-24 19:49 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.