aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2017-07-25 14:08:10 -0700
committerTim Newsome <tim@sifive.com>2017-07-25 14:08:10 -0700
commit753d15e22ce910ea75fd876851f91c2b3ab179fb (patch)
tree34998ccb1c6e990dcea5011de57c7905b055c0be /src/server
parent79329f21a3f0b9bf0a26bf3c4eb46e5e12df579a (diff)
downloadriscv-openocd-753d15e22ce910ea75fd876851f91c2b3ab179fb.zip
riscv-openocd-753d15e22ce910ea75fd876851f91c2b3ab179fb.tar.gz
riscv-openocd-753d15e22ce910ea75fd876851f91c2b3ab179fb.tar.bz2
Print out which port OpenOCD is listening on.print_port
This is essential when a test environment asks OpenOCD to listen on port 0, so that the environment can easily discover which port is actually being used.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/server.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server/server.c b/src/server/server.c
index 8009d40..65da53f 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -298,6 +298,12 @@ int add_service(char *name,
free_service(c);
return ERROR_FAIL;
}
+
+ struct sockaddr_in addr_in;
+ socklen_t addr_in_size = sizeof(addr_in);
+ getsockname(c->fd, &addr_in, &addr_in_size);
+ LOG_INFO("Listening on port %d for %s connections",
+ ntohs(addr_in.sin_port), name);
} else if (c->type == CONNECTION_STDINOUT) {
c->fd = fileno(stdin);