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); }
In reply to Pass a IO::Socket handle to a thread by bsdmeister
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |