perl: Rework socket and connection handling

Avoid deeply nested code.

Adapt connection handling to common pattern used in other bindings.

Properly share socket between threads. Before, only the callback thread
had the correct socket after an auto-reconnect. This resulted in a
SIGPIPE abort when using the old stale socket in other threads. Also
use MSG_NOSIGNAL if available to avoid abort on SIGPIPE.

There are still deadlock problems on Windows (using Strawberry Perl and
Active State Perl) that are not fixed yet. It happens if the user creates
a thread while the receive thread is blocking the socket and if the user
calls a getter or setter after an auto-reconnect while the receive thread
is blocking the socket.

Non of this problems occur with Cygwin's Perl. The suggested explanation
is that Strawberry Perl and Active State Perl are using msvcrt.dll that
contains some locking which results in this deadlock and that Cygwin has
a different implementation for this. http://perlmonks.org/?node_id=1078634
perl: Update changelog