bsdmeister has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am a newbie in Perl, used it only to work with strings in the past, but now I am doing a MSc work that makes massive usage of threads and sockets.
My goal is to pass a socket handle to a thread, so the thread can recv data.
I have read something about shared objects (where IO::Socket is not available to pass). Is there a way to pass a socket handle to a thread?
I create the socket:$server = IO::Socket::INET->new( LocalAddr=>'localhost', LocalPort=>$port, Type=>SOCK_STREAM, Proto=>'tcp', Listen=>10 ); sub protocol($server) { while(1) { if ($server->connected()) { print "Socket is here :)"; } $server->recv($data,1024); @recvData = split(/:/,$data); print $data; print $recvData; } } while(1) { print "UP\n"; $server->accept(); print $server->connected(); $p = threads->create(\&protocol => $server); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pass a IO::Socket handle to a thread
by BrowserUk (Patriarch) on Dec 02, 2012 at 23:16 UTC | |
Re: Pass a IO::Socket handle to a thread
by zentara (Archbishop) on Dec 03, 2012 at 10:44 UTC | |
by Anonymous Monk on Dec 03, 2012 at 11:22 UTC | |
Re: Pass a IO::Socket handle to a thread
by Anonymous Monk on Dec 02, 2012 at 22:30 UTC | |
by bsdmeister (Initiate) on Dec 02, 2012 at 22:53 UTC | |
by CountZero (Bishop) on Dec 02, 2012 at 23:08 UTC | |
by Anonymous Monk on Dec 02, 2012 at 23:12 UTC | |
by Anonymous Monk on Dec 02, 2012 at 22:59 UTC |
Back to
Seekers of Perl Wisdom