11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 16 • NETWORKINGwww.it-ebooks.infoThe MX records for the host specified by hostname are added to the array specified by mxhosts. If theoptional input parameter weight is supplied, the corresponding weight values will be placed there; theserefer to the hit prevalence assigned to each server identified by record. An example follows:This returns the following output:Array ( [0] => aspmx.l.google.com)ServicesAlthough we often use the word Inter<strong>net</strong> in a generalized sense, referring to it in regard to chatting,reading, or downloading the latest version of some game, what we’re actually referring to is one orseveral Inter<strong>net</strong> services that collectively define this communication platform. Examples of theseservices include HTTP, FTP, POP3, IMAP, and SSH. For various reasons (an explanation of which isbeyond the scope of this book), each service commonly operates on a particular communications port.For example, HTTP’s default port is 80, and SSH’s default port is 22. These days, the widespread need forfirewalls at all levels of a <strong>net</strong>work makes knowledge of such matters quite important. Two <strong>PHP</strong> functions,getservbyname() and getservbyport(), are available for learning more about services and theircorresponding port numbers.Retrieving a Service’s Port NumberThe getservbyname() function returns the port number of a specified service. Its prototype follows:int getservbyname(string service, string protocol)The service corresponding to service must be specified using the same name as that found in the/etc/services file. The protocol parameter specifies whether you’re referring to the tcp or udpcomponent of this service. Consider an example:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!