Skip to content

Commit

Permalink
Specify that we need TCP and not UDP connection
Browse files Browse the repository at this point in the history
Relevant man pages say that with our previous
code libc might return either. Glibc returns tcp but
bionic returns udp. So specify it explicitly
  • Loading branch information
phcoder committed May 29, 2019
1 parent 873ffc2 commit e857bb3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions uart/uart_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ serial_port uart_open(const char* pcPortName)
if (sp == 0) return INVALID_SERIAL_PORT;

if (memcmp(pcPortName, "tcp:", 4) == 0) {
struct addrinfo *addr, *rp;
struct addrinfo *addr = NULL, *rp;
char *addrstr = strdup(pcPortName + 4);
if (addrstr == NULL) {
printf("Error: strdup\n");
Expand All @@ -96,7 +96,13 @@ if (colon) {
} else
portstr = "7901";

int s = getaddrinfo(addrstr, portstr, NULL, &addr);
struct addrinfo info;

memset (&info, 0, sizeof(info));

info.ai_socktype = SOCK_STREAM;

int s = getaddrinfo(addrstr, portstr, &info, &addr);
if (s != 0) {
printf("Error: getaddrinfo: %s\n", gai_strerror(s));
return INVALID_SERIAL_PORT;
Expand Down

0 comments on commit e857bb3

Please sign in to comment.