This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgMax has uploaded this change for review. ( https://gerrit.osmocom.org/12723 Change subject: Stream examples: log sent/received bytes ...................................................................... Stream examples: log sent/received bytes Make client and server examples more verbose by logging actual bytes sent/received. Change-Id: I6979b2f92c96c2366f18bf31e4bc495a6709133a --- M examples/stream-client.c M examples/stream-server.c 2 files changed, 23 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/23/12723/1 diff --git a/examples/stream-client.c b/examples/stream-client.c index 3c3416f..6178dcd 100644 --- a/examples/stream-client.c +++ b/examples/stream-client.c @@ -45,19 +45,26 @@ static int read_cb(struct osmo_stream_cli *conn) { + int bytes; struct msgb *msg; - LOGP(DSTREAMTEST, LOGL_NOTICE, "received message from stream\n"); + LOGP(DSTREAMTEST, LOGL_NOTICE, "receiving message from stream... "); msg = msgb_alloc(1024, "STREAMCLIENT/test"); if (msg == NULL) { - LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n"); + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n"); return 0; } - if (osmo_stream_cli_recv(conn, msg) < 0) { - LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n"); + + bytes = osmo_stream_cli_recv(conn, msg); + + if (bytes < 0) { + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n"); return 0; } + + LOGPC(DSTREAMTEST, LOGL_NOTICE, "got %d (%d) bytes: %s\n", bytes, msg->len, msgb_hexdump(msg)); + msgb_free(msg); return 0; } @@ -86,7 +93,7 @@ osmo_stream_cli_send(conn, msg); - LOGP(DSTREAMTEST, LOGL_NOTICE, "message of %d bytes sent\n", msg->len); + LOGP(DSTREAMTEST, LOGL_NOTICE, "sent %d bytes message: %s\n", msg->len, msgb_hexdump(msg)); return 0; } diff --git a/examples/stream-server.c b/examples/stream-server.c index 08c3d2a..cd6dc57 100644 --- a/examples/stream-server.c +++ b/examples/stream-server.c @@ -43,19 +43,25 @@ int read_cb(struct osmo_stream_srv *conn) { + int bytes; struct msgb *msg; - LOGP(DSTREAMTEST, LOGL_NOTICE, "received message from stream\n"); + LOGP(DSTREAMTEST, LOGL_NOTICE, "receiving message from stream... "); msg = msgb_alloc(1024, "STREAMSERVER/test"); if (msg == NULL) { - LOGP(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n"); + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot allocate message\n"); return 0; } - if (osmo_stream_srv_recv(conn, msg) < 0) { - LOGP(DSTREAMTEST, LOGL_ERROR, "cannot receive message\n"); + + bytes = osmo_stream_srv_recv(conn, msg); + + if (bytes < 0) { + LOGPC(DSTREAMTEST, LOGL_ERROR, "cannot receive message: %s\n", strerror(-bytes)); return 0; - } + } else + LOGPC(DSTREAMTEST, LOGL_NOTICE, "got %d (%d) bytes: %s\n", bytes, msg->len, msgb_hexdump(msg)); + msgb_free(msg); return 0; } -- To view, visit https://gerrit.osmocom.org/12723 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: I6979b2f92c96c2366f18bf31e4bc495a6709133a Gerrit-Change-Number: 12723 Gerrit-PatchSet: 1 Gerrit-Owner: Max <msuraev at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190129/625abbb7/attachment.htm>