]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c
2 Translate the port number into a service name
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/DebugLib.h>
15 #include <Library/UefiLib.h>
17 #include <sys/socket.h>
22 /** Translate the port number into a service name
24 @param[in] Argc The number of arguments
25 @param[in] Argv The argument value array
27 @retval 0 The application exited normally.
28 @retval Other An error occurred.
37 struct servent
* pService
;
39 // Determine if the service name is specified
41 || ( 1 != sscanf ( Argv
[1], "%d", &PortNumber
))) {
42 Print ( L
"%a <port number>\r\n", Argv
[0]);
45 // Translate the port number
46 pService
= getservbyport ( htons ( PortNumber
), NULL
);
47 if ( NULL
== pService
) {
48 Print ( L
"ERROR - service not found, errno: %d\r\n", errno
);
51 Print ( L
"%a: %d, %a\r\n",