Skip to content

Commit 753d15e

Browse files
committed
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.
1 parent 79329f2 commit 753d15e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/server/server.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ int add_service(char *name,
298298
free_service(c);
299299
return ERROR_FAIL;
300300
}
301+
302+
struct sockaddr_in addr_in;
303+
socklen_t addr_in_size = sizeof(addr_in);
304+
getsockname(c->fd, &addr_in, &addr_in_size);
305+
LOG_INFO("Listening on port %d for %s connections",
306+
ntohs(addr_in.sin_port), name);
301307
} else if (c->type == CONNECTION_STDINOUT) {
302308
c->fd = fileno(stdin);
303309

0 commit comments

Comments
 (0)