Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058086]
help
Chatterbox?
[oakbox]: Anyone else having difficulty looking at search.cpan.org?
[oakbox]: I keep getting a proxy error.
[marto]: try http://metacpan. org/

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-07-26 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (388 votes). Check out past polls.