diff options
Diffstat (limited to 'src/daemon/dlt_daemon_connection.c')
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 4287623..0177bf2 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -70,6 +70,8 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn, size_t msg_size) { DltConnectionType type = DLT_CONNECTION_TYPE_MAX; + int bytes_sent = 0; + int ret = 0; if ((conn != NULL) && (conn->receiver != NULL)) { @@ -78,14 +80,22 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn, switch (type) { - case DLT_CONNECTION_CLIENT_MSG_SERIAL: - if(write(conn->receiver->fd, msg, msg_size) > 0) - return DLT_DAEMON_ERROR_OK; - return DLT_DAEMON_ERROR_UNKNOWN; - case DLT_CONNECTION_CLIENT_MSG_TCP: - return dlt_daemon_socket_sendreliable(conn->receiver->fd, msg, msg_size); - default: - return DLT_DAEMON_ERROR_UNKNOWN; + case DLT_CONNECTION_CLIENT_MSG_SERIAL: + if (write(conn->receiver->fd, msg, msg_size) > 0) + { + return DLT_DAEMON_ERROR_OK; + } + return DLT_DAEMON_ERROR_UNKNOWN; + + case DLT_CONNECTION_CLIENT_MSG_TCP: + ret = dlt_daemon_socket_sendreliable(conn->receiver->fd, + msg, + msg_size, + &bytes_sent); + conn->receiver->bytes_sent += bytes_sent; + return ret; + default: + return DLT_DAEMON_ERROR_UNKNOWN; } } @@ -124,7 +134,7 @@ int dlt_connection_send_multiple(DltConnection *con, sizeof(dltSerialHeader)); } - if ((data1 != NULL) && (ret == DLT_RETURN_OK )) + if ((data1 != NULL) && (ret == DLT_RETURN_OK)) { ret = dlt_connection_send(con, data1, size1); } |