1
0

Merge pull request #422 from ucb-bar/use-random-port-for-jtag-vpi

Use random, unused port for JTAG VPI
This commit is contained in:
Richard Xia 2016-10-26 13:16:28 -07:00 committed by GitHub
commit 8c538f548b
2 changed files with 11 additions and 4 deletions

View File

@ -40,7 +40,8 @@
#include <vpi_user.h>
#define RSP_SERVER_PORT 5555
// Calling bind with port 0 will return a socket bound to an unused port.
#define RSP_SERVER_PORT 0
#define XFERT_MAX_SIZE 512
const char * cmd_to_string[] = {"CMD_RESET",
@ -63,8 +64,6 @@ int init_jtag_server(int port)
struct sockaddr_in serv_addr;
int flags;
printf("Listening on port %d\n", port);
listenfd = socket(AF_INET, SOCK_STREAM, 0);
memset(&serv_addr, '0', sizeof(serv_addr));
@ -76,6 +75,14 @@ int init_jtag_server(int port)
listen(listenfd, 10);
socklen_t socklen = sizeof(serv_addr);
if (getsockname(listenfd, (struct sockaddr *)&serv_addr, &socklen) == -1) {
perror("init_jtag_server");
exit(1);
} else {
printf("Listening on port %d\n", ntohs(serv_addr.sin_port));
}
printf("Waiting for client connection...");
connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);
printf("ok\n");

@ -1 +1 @@
Subproject commit 83a3143e93b54d705f38588b3e14351434084bae
Subproject commit 886d8131dbd23533fb04d2d76a80be21d5f9ee7a