Networks

The Internet is really just one big network, albeit the largest and most convoluted one ever created, and there are a variety of different protocols that allow communication. The most common protocol is HTTP, followed by FTP, but there are literally dozens of others, each with their own specific purpose.

PHP has a number of ways to work over a network - the most common protocols have special functions to make often-used functionality easy, but it is possible to use PHP to write any kind of data over any kind of protocol.

The topics covered in this chapter are:

  • What sockets are, and basic socket use

  • How to use sockets outside of HTTP

  • How to create a basic server using PHP

  • Creating a web server

  • Helpful network-related functions

  • HTTP-specific and FTP-specific functions

  • The Curl library

Chapter contents

  1. 15.1. Sockets
    1. 15.1.1. Sockets are files
    2. 15.1.2. Making a simple search engine
    3. 15.1.3. Sockets aren't all about HTTP
    4. 15.1.4. Sockets can be servers
    5. 15.1.5. Sockets can be powerful
  2. 15.2. Domain resolution functions
  3. 15.3. Host and IP resolution
  4. 15.4. HTTP
    1. 15.4.1. Sending custom headers
    2. 15.4.2. Reading queued headers
    3. 15.4.3. Authentication over HTTP
    4. 15.4.4. Dynamic authentication
  5. 15.5. Sending mail
    1. 15.5.1. MIME types
    2. 15.5.2. Easier mail sending with PEAR::Mail
    3. 15.5.3. Sending mixed-type messages with PEAR::Mail_Mime
    4. 15.5.4. Sending attachments (at last!)
  6. 15.6. Reading mail
    1. 15.6.1. Opening a mailbox
    2. 15.6.2. Reading message information
    3. 15.6.3. Reading message contents
  7. 15.7. Dealing with MIME-encoded messages
  8. 15.8. Mail management
  9. 15.9. Transferring files over FTP
    1. 15.9.1. Other helpful FTP functions
  10. 15.10. Curl
    1. 15.10.1. Installing Curl
    2. 15.10.2. Your first Curl scripts
    3. 15.10.3. The abridged list of Curl options
    4. 15.10.4. Debugging Curl
  11. 15.11. Custom data stream handling
    1. 15.11.1. The Morse code stream
  12. 15.12. Summary
  13. 15.13. Exercises
  14. 15.14. Further reading
  15. 15.15. Next chapter

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Sockets >>

Previous chapter: Next chapter

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.