Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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.


Comment on Re^2: How to introduce threading in socket communication
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2015-07-30 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls