Stream examples: print accepted client address

Display socket information for accepted client.

Change-Id: I5aa6757be79754cf7ffa4a276dae1cfb80fe904e
This commit is contained in:
Max 2019-02-04 14:54:15 +01:00
parent e3366cf144
commit dee873489f
1 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <unistd.h>
#include <osmocom/core/select.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/logging.h>
@ -77,6 +78,8 @@ static int close_cb(struct osmo_stream_srv *dummy)
static int accept_cb(struct osmo_stream_srv_link *srv, int fd)
{
char buf[OSMO_SOCK_NAME_MAXLEN];
if (conn != NULL) {
LOGP(DSTREAMTEST, LOGL_ERROR, "Sorry, this example only "
"support one client simultaneously\n");
@ -91,6 +94,9 @@ static int accept_cb(struct osmo_stream_srv_link *srv, int fd)
return -1;
}
osmo_sock_get_name_buf(buf, OSMO_SOCK_NAME_MAXLEN, fd);
LOGP(DSTREAMTEST, LOGL_NOTICE, "accepted client: %s\n", buf);
return 0;
}