GETPROTOBYNAME

Use the GETPROTOBYNAME command to translate a network protocol name to a protocol number.

Format

Read syntax diagramSkip visual syntax diagram
>>-SOCKET--(--"GETPROTOBYNAME"--,--protocolname--)-------------><

Parameters

protocolname
The name of the network protocol

Returned value

This command returns a string that contains the return code and the protocol number, for example, 0 6. The return code can be 0 or the REXX API error number. The return code 0 indicates that the requested socket command was completed successfully.

See Socket call error return codes for additional information about the numeric error codes that are returned by this command.

The following REXX socket API error numbers can be returned:
  • 2001 EINVALIDRXSOCKETCALL
  • 2005 ESUBTASKNOTACTIVE

LE C/C++ equivalent

struct protoent *getprotobyname(char name); 

Code example

Figure 1. GETPROTOBYNAME command example
/* REXX EZARXR15 */
/*
 * This sample demonstrates the use of the GETPROTOBYNAME
 * socket command.
 */
if perror(socket("INITIALIZE","MYSET01"),"INITIALIZE") = 0,
   then do
     src = socket("GETPROTOBYNAME","TCP");
     Say "The TCP protocol is assigned the number of",
         WORD(src,2);
   end;
src = perror(socket("TERMINATE","MYSET01"),"TERMINATE");
exit 0;

/* This routine returns -1 if the first word if arg 1 is not zero */
perror: if word(arg(1),1) = 0 then return 0; else
    Say arg(2) "Error : "arg(1);
    return -1;