Changeset a62ceaf in mainline for uspace/app/netecho/netecho.c


Ignore:
Timestamp:
2016-02-29T19:19:19Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
129b92c6
Parents:
5147ff1
Message:

Need better interfaces for handling internet host and host:port specifications.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/netecho/netecho.c

    r5147ff1 ra62ceaf  
    115115        printf("syntax:\n");
    116116        printf("\t%s -l <port>\n", NAME);
    117         printf("\t%s -d <host> <port> [<message> [<message...>]]\n", NAME);
     117        printf("\t%s -d <host>:<port> [<message> [<message...>]]\n", NAME);
    118118}
    119119
     
    151151int main(int argc, char *argv[])
    152152{
    153         char *host;
     153        char *hostport;
    154154        char *port;
    155155        char **msgs;
     
    167167                }
    168168
    169                 host = NULL;
    170169                port = argv[2];
    171170                msgs = NULL;
     171
     172                rc = comm_open_listen(port);
     173                if (rc != EOK) {
     174                        printf("Error setting up communication.\n");
     175                        return 1;
     176                }
    172177        } else if (str_cmp(argv[1], "-d") == 0) {
    173                 if (argc < 4) {
     178                if (argc < 3) {
    174179                        print_syntax();
    175180                        return 1;
    176181                }
    177182
    178                 host = argv[2];
    179                 port = argv[3];
    180                 msgs = argv + 4;
     183                hostport = argv[2];
     184                port = NULL;
     185                msgs = argv + 3;
     186
     187                rc = comm_open_talkto(hostport);
     188                if (rc != EOK) {
     189                        printf("Error setting up communication.\n");
     190                        return 1;
     191                }
    181192        } else {
    182193                print_syntax();
    183                 return 1;
    184         }
    185 
    186         rc = comm_open(host, port);
    187         if (rc != EOK) {
    188                 printf("Error setting up communication.\n");
    189194                return 1;
    190195        }
Note: See TracChangeset for help on using the changeset viewer.