3.10. An Exercise

The chapter is "officially" over (wink, wink). The following two listings are only an exercise. Example 3-16 contains a remote debugging console. This console window can run on any computer on your network (or it can run on your only computer if you are processor-challenged). It just sits there, waiting for messages from the RemoteDebug class, which is shown in Example 3-17. To run the remote debug console, compile Example 3-16 and type the following code on the command line:

C:\>listener 1969

This line causes the remote console to wait for messages on port 1969.

Example 3-16 can be compiled from the command line as follows:

vbc /t:exe /r:system.dll listener.vb

Example 3-17 contains the listing for the RemoteDebug class, which sends messages to the remote debug console. It also contains a small test class so you can compile the class to an executable and test it. Once the remote debug console is started, you have to open up a second console window to run the executable containing the RemoteDebug class (assuming you are testing and listening on the same machine).

Example 3-17, however, wires the remote debug class into the Log example from Example 3-9 earlier in the chapter. It can be compiled the same way as Example 3-16.

Example 3-16. Remote debug console
'references: system.dll Imports System Imports System.Net Imports System.Net.Sockets Imports System.Text Public Class Listener Implements IDisposable Private port As Integer Private myListener As TcpListener ...

Get Object-Oriented Programming with Visual Basic .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.