Changes in uspace/app/nterm/conn.c [204ba47:a62ceaf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nterm/conn.c
r204ba47 ra62ceaf 37 37 #include <errno.h> 38 38 #include <fibril.h> 39 #include <inet/dnsr.h>40 39 #include <inet/endpoint.h> 40 #include <inet/hostport.h> 41 41 #include <inet/tcp.h> 42 42 #include <stdio.h> … … 86 86 } 87 87 88 int conn_open(const char *host , const char *port_s)88 int conn_open(const char *hostport) 89 89 { 90 90 inet_ep2_t epp; 91 const char *errmsg; 92 int rc; 91 93 92 /* Interpret as address */ 93 inet_addr_t iaddr; 94 int rc = inet_addr_parse(host, &iaddr); 95 94 inet_ep2_init(&epp); 95 rc = inet_hostport_plookup_one(hostport, ip_any, &epp.remote, NULL, 96 &errmsg); 96 97 if (rc != EOK) { 97 /* Interpret as a host name */ 98 dnsr_hostinfo_t *hinfo = NULL; 99 rc = dnsr_name2host(host, &hinfo, ip_any); 100 101 if (rc != EOK) { 102 printf("Error resolving host '%s'.\n", host); 103 goto error; 104 } 105 106 iaddr = hinfo->addr; 107 } 108 109 char *endptr; 110 uint16_t port = strtol(port_s, &endptr, 10); 111 if (*endptr != '\0') { 112 printf("Invalid port number %s\n", port_s); 98 printf("Error: %s (host:port %s).\n", errmsg, hostport); 113 99 goto error; 114 100 } 115 101 116 inet_ep2_init(&epp);117 epp.remote.addr = iaddr;118 epp.remote.port = port;119 120 printf("Connecting to host %s port %u\n", host, port);102 printf("Connecting to %s\n", hostport); 103 char *s; 104 rc = inet_addr_format(&epp.remote.addr, &s); 105 if (rc != EOK) 106 goto error; 121 107 122 108 rc = tcp_create(&tcp);
Note:
See TracChangeset
for help on using the changeset viewer.