# HG changeset patch # User Matti Hamalainen # Date 1337823201 -10800 # Node ID 318a71f4f57f21cfabe8eb556247f59fe43a85ec # Parent a21cc444d8007b1106906b1b6ec5a7a7a46fd284 Rename some internal variables and add new buffer pointer one. diff -r a21cc444d800 -r 318a71f4f57f libnnchat.c --- a/libnnchat.c Thu May 24 00:56:15 2012 +0300 +++ b/libnnchat.c Thu May 24 04:33:21 2012 +0300 @@ -358,11 +358,12 @@ { if (conn != NULL) { - conn->ptr = conn->buf; - conn->got = conn->total = 0; + conn->got_ptr = conn->buf; + conn->got_bytes = conn->total_bytes = 0; } } + int nn_conn_pull(nn_conn_t *conn) { int result; @@ -389,14 +390,14 @@ } else if (FD_ISSET(conn->socket, &tmpfds)) { - conn->got = recv(conn->socket, conn->ptr, NN_CONNBUF_SIZE - conn->total, 0); - if (conn->got < 0) + conn->got_bytes = recv(conn->socket, conn->got_ptr, NN_CONNBUF_SIZE - conn->total_bytes, 0); + if (conn->got_bytes < 0) { conn->err = nn_get_socket_errno(); nn_conn_err(conn, "Error in recv: %d, %s\n", conn->err, nn_get_socket_errstr(conn->err)); return -2; } - else if (conn->got == 0) + else if (conn->got_bytes == 0) { nn_conn_err(conn, "Server closed connection.\n"); conn->status = NN_CONN_CLOSED; @@ -404,9 +405,8 @@ } else { - /* Handle protocol data */ - conn->total += conn->got; - conn->ptr += conn->got; + conn->total_bytes += conn->got_bytes; + conn->got_ptr += conn->got_bytes; return 0; } } @@ -414,6 +414,7 @@ return 1; } + BOOL nn_conn_check(nn_conn_t *conn) { if (conn == NULL) @@ -423,7 +424,6 @@ } - BOOL nn_network_init(void) { #ifdef __WIN32 diff -r a21cc444d800 -r 318a71f4f57f libnnchat.h --- a/libnnchat.h Thu May 24 00:56:15 2012 +0300 +++ b/libnnchat.h Thu May 24 04:33:21 2012 +0300 @@ -100,8 +100,8 @@ int status; char buf[NN_CONNBUF_SIZE + 16]; - char *ptr; - ssize_t got, total; + char *ptr, *got_ptr; + ssize_t got_bytes, total_bytes; } nn_conn_t;