getservbyport 


Apache apg

GETS the Internet service which corresponds to port and protocol.



<?php

str
|false getservbyport int $port str $protocol )


where,

$port The port number

$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 >PORT</td><td>PROTOCOL</td></tr>
<?php

$port01 
= [808121222314325437079110443];

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


 RESULT   

SOME tcp SERVICES
PORTPROTOCOL
80http
81hosts2-ns
21ftp
22ssh
23telnet
143imap
25smtp
43nicname
70gopher
79finger
110pop3
443https
ed48

  2 EXERCISE   

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

for ($prt03 1$prt03 <= 10000$prt03++)

 {  if(
getservbyport($prt03'tcp')) { ?>
 
    </tr><td><?php echo $prt03?></td><td><?php echo getservbyport($prt03'tcp'); ?></td></tr>
    
 <?php } } ?>
</tr><tr><td colspan="2">ed48</td></tr></tbody></table>


  3 EXERCISE   

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

for ($prt02 1$prt02 <= 10000$prt02++)

 {  if(
getservbyport($prt02'udp')) { ?>
 
    </tr><td><?php echo $prt02?></td>
    <td><?php echo getservbyport($prt02'udp'); ?></td></tr>
    
 <?php } } ?>
</tr><tr><td colspan="2">ed48</td></tr></tbody></table>