getservbyname

Get port number associated with an Internet service and protocol

Syntax

getservbyname ( string $service , string $protocol ) : int

Parameters

service

The Internet service name, as a string.

protocol

protocol is either "tcp" or "udp" (in lowercase).

Return

Returns the port number, or FALSE if service or protocol is not found.

Examples

1 · service protocol

<?

$service = "http";
$protocol = "tcp";

$return = getservbyname($service, $protocol);

echo $return;

?>
80

2 · 1

<?

$array = array("finger", "ftp", "gopher", "http", "imap", "nicname", "pop3", "smtp", "ssh", "telnet", "www");
$protocol = "tcp";

foreach ($array as $service)
{
    $return = getservbyname($service, $protocol);

    echo "$service: $return\n";
}

?>
finger: 79
ftp: 21
gopher: 70
http: 80
imap: 143
nicname: 43
pop3: 110
smtp: 25
ssh: 22
telnet: 23
www: 80

checkdnsrr

closelog

dns_check_record

dns_get_mx

dns_get_record

fsockopen

gethostbyaddr

gethostbyname

gethostbynamel

gethostname

getmxrr

getprotobyname

getprotobynumber

getservbyport

header

header_register_callback

header_remove

headers_list

headers_sent

http_response_code

inet_ntop

inet_pton

ip2long

long2ip

openlog

pfsockopen

setcookie

setrawcookie

socket_get_status

socket_set_blocking

socket_set_timeout

syslog

PHP

Home Menu