Print out which port OpenOCD is listening on.

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.
print_port
Tim Newsome 2017-07-25 14:08:10 -07:00
parent 79329f21a3
commit 753d15e22c
1 changed files with 6 additions and 0 deletions

View File

@ -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);