Changes in uspace/app/nettest3/nettest3.c [9d58539:0aa70f4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest3/nettest3.c
r9d58539 r0aa70f4 39 39 #include <str.h> 40 40 41 #include <inet/dnsr.h> 41 42 #include <net/in.h> 42 43 #include <net/in6.h> … … 60 61 int fd; 61 62 char *endptr; 63 dnsr_hostinfo_t *hinfo; 62 64 63 65 port = 7; 64 66 65 data = (char *) "Hello World!";67 data = (char *) "Hello World!"; 66 68 size = str_size(data); 67 69 … … 75 77 rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr); 76 78 if (rc != EOK) { 77 fprintf(stderr, "Error parsing address\n"); 78 return 1; 79 /* Try interpreting as a host name */ 80 rc = dnsr_name2host(argv[1], &hinfo, AF_INET); 81 if (rc != EOK) { 82 printf("Error resolving host '%s'.\n", argv[1]); 83 return rc; 84 } 85 86 uint16_t af = inet_addr_sockaddr_in(&hinfo->addr, &addr, NULL); 87 if (af != AF_INET) { 88 printf("Host '%s' not resolved as IPv4 address.\n", argv[1]); 89 return rc; 90 } 79 91 } 80 92 printf("result: rc=%d, family=%d, addr=%x\n", rc, … … 98 110 99 111 printf("connect()\n"); 100 rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr));112 rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr)); 101 113 printf(" -> %d\n", rc); 102 114 if (rc != 0) … … 115 127 } while (rc > 0); 116 128 117 async_usleep(1000 *1000);129 async_usleep(1000 * 1000); 118 130 119 131 printf("closesocket()\n"); … … 124 136 } 125 137 126 127 138 /** @} 128 139 */
Note:
See TracChangeset
for help on using the changeset viewer.