The line in question is trying to assign $send_socket to a shared structure. $send_socket is a IO::Socket::INET object. Internally, that is a hash, probably containing other nested data structures.
You would need to share that hash, and everything in it to be able to assign it to a shared hash. You cannot.
There are two reasons for this.
This is because blessing, involves associating (through internal linking (termed "magic")), the data pointed at by that reference with code (the object methods). But Perl cannot run code across threads.
An object without it's instance data is not going to work.
I have seen a reference that says that you can share Perl's object's across threads. The trick (apparently) is to re-bless the (copy of the) object handle available in the (other, non creating) threads where you want to use it.
This is a fine idea, but for it to work, you would first have to deep copy all of the contents of the blessed reference into a previously shared hash. You also have to copy any and all nested data structures referenced from it into new, shared equivalents.
I have tried to do this for some fairly simple objects, but it is very, very, very hard to do at the Perl level. Discovering the structures, and their classes for something as complex as an IO::Handle::INET object would be fraught with problems.
Basically what I am saying is that I cannot do what you are trying to do, and I know of noone who has succeeded in doing it.
If you decide to go ahead and try it anyway, I think that you are very much on your own:
Very few people will even consider trying to render assistance if you tell them that you are trying to share objects between threads. Even fewer will be responsive to bug reports against modules if you tell them you are encountering problems with their modules, when trying to share objects across threads.
I wish it wasn't so, but it is.
Good luck.
In reply to Re^2: Declaring/Assigning thread shared vars
by BrowserUk
in thread Declaring/Assigning thread shared vars
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |