Changes in uspace/app/nterm/conn.c [a62ceaf:204ba47] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nterm/conn.c
ra62ceaf r204ba47 37 37 #include <errno.h> 38 38 #include <fibril.h> 39 #include <inet/dnsr.h> 39 40 #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 port)88 int conn_open(const char *host, const char *port_s) 89 89 { 90 90 inet_ep2_t epp; 91 const char *errmsg;92 int rc;93 91 94 inet_ep2_init(&epp); 95 rc = inet_hostport_plookup_one(hostport, ip_any, &epp.remote, NULL, 96 &errmsg); 92 /* Interpret as address */ 93 inet_addr_t iaddr; 94 int rc = inet_addr_parse(host, &iaddr); 95 97 96 if (rc != EOK) { 98 printf("Error: %s (host:port %s).\n", errmsg, hostport); 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); 99 113 goto error; 100 114 } 101 115 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;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); 107 121 108 122 rc = tcp_create(&tcp);
Note:
See TracChangeset
for help on using the changeset viewer.