%SS_GETSERVBYPORT

Return the service name given the port number

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
status = %SS_GETSERVBYPORT(port, [type], service, protocol)

Return value

status

Returns SS_SUCCESS (0) or one of the errors in Error codes returned by %SS_GETSERVBYPORT below. (n)

Arguments

port

The port number for which to return a service name. (n)

type

(optional) One of the following types of protocols to access the service: (a)

tcp = Transmission control protocol.

udp = User datagram protocol.

service

Returned with the name of the service on the specified port. (a)

protocol

Returned with the name of the network protocol on the specified port. (a)

Discussion

%SS_GETSERVBYPORT gets the service name and network protocol from the services file for the specified port number (and optional protocol type). This file is the TCP/IP services file on Windows; the /etc/services file on UNIX; and sys$system:tcpip$services.dat on OpenVMS. (On OpenVMS, this is not a text file that you can edit directly as is the case on Windows and UNIX; rather it’s a binary file, which can be edited with sys$manager:tcpip$config.com.)

If type is not specified, the first match is returned, and protocol will be either “tcp” or “udp.”

If SS_ENULL is returned, the system error code can be returned by immediately calling %SYSERR.

Error codes returned by %SS_GETSERVBYPORT

See the Socket Errors table for additional information about these errors.

SS_EINTR

SS_ENETDOWN

SS_ENULL

SS_HOST_NOT_FOUND

SS_NO_DATA

SS_NO_RECOVERY

SS_TRY_AGAIN

Examples

The example below returns the service name and protocol for port 5555.

status = %ss_getservbyport(5555, tcp, name, proto)