Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Can I/O operations on the same IO::Socket be executed in different threads?

by Anonymous Monk
on May 13, 2015 at 00:27 UTC ( [id://1126482]=note: print w/replies, xml ) Need Help??


in reply to Re: Can I/O operations on the same IO::Socket be executed in different threads?
in thread Can I/O operations on the same IO::Socket be executed in different threads?

Just to clarify—you are saying that the concerns in IO::Socket::SSL + fork problem do not apply in this case?

How do you envision such socket being managed? Perusing threads::shared and my $sock :shared; will ensure coherent state? The Net::SSLeay itself is thread-safe, but does it support shared sockets? Any special concerns, such as nonblocking mode or cross-thread callbacks?

Replies are listed 'Best First'.
Re^3: Can I/O operations on the same IO::Socket be executed in different threads?
by noxxi (Pilgrim) on May 13, 2015 at 19:09 UTC

    Once the SSL socket is established all the necessary state for reading and writing is fully managed by the OpenSSL library. That is the Perl socket can be used between multiple threads, but only one thread should use the socket at one time (i.e. needs locking). Forking is different because in this case the SSL state gets duplicated and client and server try to manage their own state independently which will not work because then none of these will reflect the real state of the SSL connection.

    Of course all this means that the Socket must be created before the threads are created. Creating a socket in one thread and then using it in another will not work since the Perl handle can not be shared.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-03-28 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found