]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetServByName/GetServByName.c
41deb194b1a5bbacbe677dbbd763cbf4bb9046a9
2 Translate the service name into a port number
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/DebugLib.h>
14 #include <Library/UefiLib.h>
16 #include <sys/socket.h>
21 /** Translate the service name into a port number
23 @param[in] Argc The number of arguments
24 @param[in] Argv The argument value array
26 @retval 0 The application exited normally.
27 @retval Other An error occurred.
36 struct servent
* pService
;
38 // Determine if the service name is specified
40 Print ( L
"%a <service name>\r\n", Argv
[0]);
43 // Translate the service name
44 pService
= getservbyname ( Argv
[1], NULL
);
45 if ( NULL
== pService
) {
46 Print ( L
"ERROR - service not found, errno: %d\r\n", errno
);
49 PortNumber
= htons ( pService
->s_port
);
50 Print ( L
"%a: %d, %a\r\n",