in reply to How to share sockets between threads

You don't show how you intend to use threads, so I'll assume you're going to spawn N worker threads, and pass the sockets to them as needed via a Thread::Queue object.

GLOB's can't be threads::shared, and aren't scalars, so they can't be passed over Thread::Queue (which is just a threads::shared array). However, you *can* get the fileno of the socket after accept()'ing, and pass it to the worker instead: (The following code hasn't been tested, its just an outline)

my $thrdq = Thread::Queue->new(); my @thrds = (); push @thrds, threads->new(\&runworker) foreach (1..$num_of_threads); while( my $newClient = $server->accept ) { $thrdq->enqueue(fileno($newClient)); } sub runworker { my $sktno = $thrdq->dequeue(); my $client = IO::Socket::INET->new(); $client->fdopen($fn, '+>>'); print $client "CLIENT: some stuff\n" }
IIRC, you'll also need to wait for the work thread to pick up the fileno before accepting another connection, or the master may cause a socket close when it accepts the next connection.