When calling 'connect()' in nonblocking mode and the connection has been established, don't call 'tcp_connect()' again, which would trigger an assertion with the message 'tcp_connect: can only connect from state CLOSED'. Fixes #2039
Thanks to Menno Valkema for the patch.
Otherwise, the assertion "already writing or closing" may fail.
Issue #1327.
Issue #1082