getservbyname 


Apache apg

GETS the PORT number associated with a particular service and protocol.





This function returns FALSE if service or protocol is not found.



<?php

int
|false getservbyname str $service str $protocol )


where,

$service The Internet service name

$protocol 
The protocol tcp or udp
                  
lowercase )
  
?>

  $port   


The port number.



  $protocol   


The protocol lowercase name tcp or udp.



 Transmission Control Protocol (TCP) 


Is one of the main protocols of the Internet protocol suite.

It originated in the initial network implementation in which it complemented the Internet Protocol,(IP).

Therefore, the entire suite is commonly referred to as TCP/IP.

TCP provides reliable, ordered, and error-checked delivery of a stream of octets, (bytes), between applications running on hosts communicating via an IP network.

Major internet applications such as the World Wide Web, email, remote administration, and file transfer rely on TCP.



 User Datagram Protocol (UDP) 


Is one of the core members of the Internet protocol suite.

The protocol was designed by David P. Reed in 1980 and formally defined in RFC 768.

   User Datagram Protocol  !


With UDP, computer applications can send messages, in this case referred to as datagrams, to other hosts on an Internet Protocol,(IP) network.



  1 EXERCISE   

<table width="100%" cellspacing="3" cellpadding="3" 
border="1" align="center">
<tbody><tr><td colspan="2">SOME tcp SERVICES</td></tr>
<tr><td>PROTOCOL</td><td>PORT</td></tr>
<?php

$servs01 
= ['http''ftp''ssh''telnet''imap',
'smtp''nicname''gopher''finger''pop3''www''https'];

foreach (
$servs01 as $serv01) { ?>
    </tr><td><?php echo $serv01?></td>
    <td><?php echo getservbyname($serv01'tcp'); ?></td></tr>
    
<?php ?>
</tr><tr><td colspan="2">ed48</td></tr></tbody></table>


  2 EXERCISE   

<table width="100%" cellspacing="3" cellpadding="3" 
border="1" align="center"><tbody><tr><td colspan="2">SOME udp SERVICES</td>
</tr><tr><td>PROTOCOL</td><td>PORT</td></tr>
<?php

$servs01 
= ['echo''discard''time''kerberos''snmp',
'https''syslog''http-rpc-epmap''doom''pop3s''phone''rasadv'];

foreach (
$servs01 as $serv01) { ?>
    </tr><td><?php echo $serv01?></td>
    <td><?php echo getservbyname($serv01'udp'); ?></td></tr>
    
<?php ?>
</tr><tr><td colspan="2">ed48</td></tr></tbody></table>