diff options
author | Max <msuraev@sysmocom.de> | 2019-02-20 17:12:34 +0100 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2019-02-20 17:33:32 +0100 |
commit | af63d87a76ef4ae010e230d86ce9c07c6081cb80 (patch) | |
tree | fa0106633f0016b0b9b5fb5644d729f6e1fd2492 /examples | |
parent | fe3527da2ac691c961f767c97d70bfe00d1e4d10 (diff) |
Stream client: add disconnect callback
It's similar to connect_cb() but called once client has been
disconnected.
Change-Id: I905adb2d6191216551a3bcdcd1aec1f96f01612a
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ipa-stream-client.c | 8 | ||||
-rw-r--r-- | examples/stream-client.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c index 2151090..ec7d2b3 100644 --- a/examples/ipa-stream-client.c +++ b/examples/ipa-stream-client.c @@ -54,6 +54,13 @@ void sighandler(int foo) exit(EXIT_SUCCESS); } +static int disconnect_cb(struct osmo_stream_cli *conn) +{ + LOGP(DIPATEST, LOGL_NOTICE, "disconnected\n"); + + return 0; +} + static int connect_cb(struct osmo_stream_cli *conn) { int *__num_msgs = osmo_stream_cli_get_data(conn); @@ -176,6 +183,7 @@ int main(int argc, char *argv[]) osmo_stream_cli_set_addr(conn, "127.0.0.1"); osmo_stream_cli_set_port(conn, 10000); osmo_stream_cli_set_connect_cb(conn, connect_cb); + osmo_stream_cli_set_disconnect_cb(conn, disconnect_cb); osmo_stream_cli_set_read_cb(conn, read_cb); osmo_stream_cli_set_data(conn, &num_msgs); diff --git a/examples/stream-client.c b/examples/stream-client.c index e2fb901..f590f25 100644 --- a/examples/stream-client.c +++ b/examples/stream-client.c @@ -43,6 +43,13 @@ static int connect_cb(struct osmo_stream_cli *conn) return 0; } +static int disconnect_cb(struct osmo_stream_cli *conn) +{ + LOGP(DSTREAMTEST, LOGL_NOTICE, "disconnected: %s\n", osmo_stream_cli_get_sockname(conn)); + + return 0; +} + static int read_cb(struct osmo_stream_cli *conn) { int bytes; @@ -121,6 +128,7 @@ int main(void) osmo_stream_cli_set_addr(conn, "127.0.0.1"); osmo_stream_cli_set_port(conn, 10000); osmo_stream_cli_set_connect_cb(conn, connect_cb); + osmo_stream_cli_set_disconnect_cb(conn, disconnect_cb); osmo_stream_cli_set_read_cb(conn, read_cb); if (osmo_stream_cli_open(conn) < 0) { |