libtls: Use poll(2) instead of select() in tls_socket