HomePHP Adding Methods to the Query Processor in PHP
Adding Methods to the Query Processor in PHP
Over this second article in a series covering network programming in PHP, you will learn how to run popular Windows network monitoring utilities, such as the “ping,” “netstat” and “ipconfig” programs, by adding some new methods to the “QueryProcessor” class introduced in the previous article.
Want to learn more about the basics of network programming in PHP? Look no further. Welcome to the second part of the series "Network Programming in PHP." This set of three tutorials teaches how to use numerous networking PHP built-in functions in a practical way, in order to build a query processor in PHP 5, which can be used to perform some of the most common network operations.
As usual, I'd like to step back for a moment to the previous article of the series, and refresh your memory of some of the topics that I explored in that tutorial. In this way, you'll be able to pick up the flow of the concepts that I'll deploy in the next few lines, without needing to reread the prior article.
As you'll probably recall, in the first part of the series, I went through the basics of using many native PHP functions included in its networking library, and started constructing an extensible query processor class in PHP 5. During this coding experience, you hopefully learned how convert host names to their corresponding IP addresses and vice versa, how to find the number of a given TCP port that is used by a specific service, and how to list the services in conjunction with their corresponding port numbers.
Even though most of these tasks can be considered trivial operations, they should be taken into account as an introductory and educational exercise, useful for tackling more complex PHP projects that require the implementation of advanced network programming routines. This might eventually include working with low-level sockets, handling DNS records, reading and writing socket streams, and so forth.
Right, at this point I guess that all the networking PHP built-in functions that I covered in the first article, such as the "gethostbyaddr()", "gethostbyname()", "gethostbynamel()" functions are already familiar to you. So now I will explain what new things you'll learn in this second article of the series. Since I want to continue expanding the "QueryProcessor" class that I coded previously, this installment will focus on adding more methods to it, by using other useful PHP network functions, aimed particularly at running popular Windows networking applications, like "ipconfig," "netstat" and more.
Having established the goals for this article, let's move on and see how the "QueryProcessor" class can be expanded by aggregating more network-based methods. Let's get started.