MCPcopy Create free account
hub / github.com/F-Stack/f-stack / connect_to_socket

Function connect_to_socket

dpdk/app/test/test_telemetry_data.c:531–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531static int
532connect_to_socket(void)
533{
534 char buf[BUF_SIZE];
535 int sock, bytes;
536 struct sockaddr_un telem_addr;
537
538 sock = socket(AF_UNIX, SOCK_SEQPACKET, 0);
539 if (sock < 0) {
540 printf("\n%s: Error creating socket: %s\n", __func__,
541 strerror(errno));
542 return -1;
543 }
544 telem_addr.sun_family = AF_UNIX;
545 snprintf(telem_addr.sun_path, sizeof(telem_addr.sun_path),
546 "%s/dpdk_telemetry.%s", rte_eal_get_runtime_dir(),
547 TELEMETRY_VERSION);
548 if (connect(sock, (struct sockaddr *) &telem_addr,
549 sizeof(telem_addr)) < 0) {
550 printf("\n%s: Error connecting to socket: %s\n", __func__,
551 strerror(errno));
552 close(sock);
553 return -1;
554 }
555
556 bytes = read(sock, buf, sizeof(buf) - 1);
557 if (bytes < 0) {
558 printf("%s: Error with socket read - %s\n", __func__,
559 strerror(errno));
560 close(sock);
561 return -1;
562 }
563 buf[bytes] = '\0';
564 printf("\n%s: %s\n", __func__, buf);
565 return sock;
566}
567
568static int
569telemetry_data_autotest(void)

Callers 1

telemetry_data_autotestFunction · 0.85

Calls 7

snprintfFunction · 0.85
rte_eal_get_runtime_dirFunction · 0.85
socketClass · 0.50
printfFunction · 0.50
connectFunction · 0.50
closeFunction · 0.50
readFunction · 0.50

Tested by

no test coverage detected