Mercurial > hg > nnchat
changeset 170:8d4cdbeae606
Clean up connection forming.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Nov 2010 02:06:16 +0200 |
parents | fd93de78a115 |
children | 35b1714eb3b2 |
files | nnchat.c |
diffstat | 1 files changed, 4 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/nnchat.c Mon Nov 15 02:05:33 2010 +0200 +++ b/nnchat.c Mon Nov 15 02:06:16 2010 +0200 @@ -925,12 +925,11 @@ /* To emulate the official client, we first make a request for * policy file, even though we don't use it for anything... */ - if ((conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, 843)) == NULL) { + conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, 843); + if (!nn_conn_check(conn)) { THERR("Policy file request connection setup failed!\n"); goto err_exit; } - if (!nn_conn_check(conn)) - goto err_exit; tmpStr = "<policy-file-request/>"; if (nn_conn_send_buf(conn, tmpStr, strlen(tmpStr) + 1) == FALSE) { @@ -947,12 +946,11 @@ nn_conn_close(conn); /* Okay, now do the proper connection ... */ - if ((conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, optPort)) == NULL) { + conn = nn_conn_open((struct in_addr *) tmpHost->h_addr, optPort); + if (!nn_conn_check(conn)) { THERR("Main connection setup failed!\n"); goto err_exit; } - if (!nn_conn_check(conn)) - goto err_exit; THMSG(1, "Connected, logging in as '%s', site '%s'.\n", optUserName, optSite); optUserName2 = nn_dblencode_str(optUserName);