Changeset a62ceaf in mainline for uspace/app/nterm
- Timestamp:
- 2016-02-29T19:19:19Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 129b92c6
- Parents:
- 5147ff1
- Location:
- uspace/app/nterm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nterm/conn.c
r5147ff1 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); -
uspace/app/nterm/conn.h
r5147ff1 ra62ceaf 39 39 #include <sys/types.h> 40 40 41 extern int conn_open(const char * , const char *);41 extern int conn_open(const char *); 42 42 extern int conn_send(void *, size_t); 43 43 -
uspace/app/nterm/nterm.c
r5147ff1 ra62ceaf 104 104 static void print_syntax(void) 105 105 { 106 printf("syntax: nterm <host> 106 printf("syntax: nterm <host>:<port>\n"); 107 107 } 108 108 … … 112 112 int rc; 113 113 114 if (argc != 3) {114 if (argc != 2) { 115 115 print_syntax(); 116 116 return 1; 117 117 } 118 118 119 rc = conn_open(argv[1] , argv[2]);119 rc = conn_open(argv[1]); 120 120 if (rc != EOK) { 121 121 printf("Error connecting.\n");
Note:
See TracChangeset
for help on using the changeset viewer.