sscall

UDP based voice chat
git clone git://git.2f30.org/sscall.git
Log | Files | Refs | README | LICENSE

commit 2b468f12ea8aa9bf49ffebf3d927804cda8cacee
parent 78572dd0e779b092461302ceed5540c76c08de2b
Author: sin <sin@2f30.org>
Date:   Mon Jun  4 14:58:19 +0100

sscall: Use getnameinfo() when verbose output is enabled

Just print the number of bytes received and the peer's
address info when the verbose enable flag is set.


Diffstat:
sscall.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/sscall.c b/sscall.c @@ -171,6 +171,7 @@ main(int argc, char *argv[]) struct sockaddr_storage their_addr; char *prog; int c; + char host[NI_MAXHOST]; prog = *argv; while ((c = getopt(argc, argv, "hb:c:r:d:v")) != -1) { @@ -321,8 +322,18 @@ main(int argc, char *argv[]) sizeof(buf), MSG_DONTWAIT, (struct sockaddr *)&their_addr, &addr_len); - if (bytes > 0) + if (bytes > 0) { + if (fverbose) { + ret = getnameinfo((struct sockaddr *)&their_addr, + addr_len, host, + sizeof(host), NULL, 0, 0); + if (ret < 0) + warn("%s", strerror(errno)); + printf("Received %ld bytes from %s\n", + bytes, host); + } do_output_pcm(buf, bytes); + } } while (1); ao_close(device);