tcp_connect: Fix closing the listening socket

As reported by Stanislav Shwartsman (@stlintel), since c0916cf0710a
("Restore SlirpAddPollCb, {,un}register_poll_fd"), tcp_connect() was closing
the just-accepted socket instead of the listening socket.

This was affecting the one-shot listeners created by tcp_emu() (FTP
PORT/PASV data connections, ksh, IRC DCC, realaudio)

Fixes #108
diff --git a/src/tcp_subr.c b/src/tcp_subr.c
index c2cb199..19d741f 100644
--- a/src/tcp_subr.c
+++ b/src/tcp_subr.c
@@ -526,6 +526,20 @@
         tcp_close(sototcpcb(so)); /* This will sofree() as well */
         return;
     }
+
+    /* Close the accept() socket, set right state */
+    if (inso->so_state & SS_FACCEPTONCE) {
+        /* If we only accept once, close the accept() socket */
+        slirp_unregister_poll_socket(so);
+        closesocket(so->s);
+
+        /* Don't select it yet, even though we have an FD */
+        /* if it's not FACCEPTONCE, it's already NOFDREF */
+        so->so_state = SS_NOFDREF;
+
+        /* We can now replace the socket in so */
+    }
+
     so->s = s;
     slirp_set_nonblock(s);
     slirp_register_poll_socket(so);
@@ -537,16 +551,6 @@
     so->fhost.ss = addr;
     sotranslate_accept(so);
 
-    /* Close the accept() socket, set right state */
-    if (inso->so_state & SS_FACCEPTONCE) {
-        /* If we only accept once, close the accept() socket */
-        slirp_unregister_poll_socket(so);
-        closesocket(so->s);
-
-        /* Don't select it yet, even though we have an FD */
-        /* if it's not FACCEPTONCE, it's already NOFDREF */
-        so->so_state = SS_NOFDREF;
-    }
     so->so_state |= SS_INCOMING;
 
     so->so_iptos = tcp_tos(so);