downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
Last updated: Mon, 16 Jul 2012


(PHP 4, PHP 5)

getservbyname --  Get port number associated with an Internet service and protocol


int getservbyname ( string service, string protocol )

getservbyname() returns the Internet port which corresponds to service for the specified protocol as per /etc/services. protocol is either "tcp" or "udp" (in lowercase). Returns FALSE if service or protocol is not found.

例子 1. getservbyname() example

= array('http', 'ftp', 'ssh', 'telnet', 'imap',
'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www');

foreach (
$services as $service) {                   
$port = getservbyname($service, 'tcp');
$service . ": " . $port . "<br />\n";

For complete list of port numbers see:

See also: getservbyport().

 Last updated: Mon, 16 Jul 2012
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at:
Last updated: Thu Jul 7 19:13:47 2005 CST