PORTINFO - a port watching utility
==================================

by Nick Gammon <nick@gammon.com.au>

http://www.gammon.com.au

Date: 2nd April 1998



Purpose
-------

This program is designed to be used by server or MUD administrators when a MUD or MUSH is down for some reason, or has relocated. The program listens on specified ports and if someone attempts to connect, sends a message and then disconnects immediately. The message could be something like "server down, please try again later", or "this game has moved to xxx.yyy.zzz port 1234".


Design
------

The program is written for Win32 (Windows 95 or Windows NT). It uses multiple threads (one per port, and briefly, one per connection) to easily monitor many ports, if necessary.

It can be installed as a service, if it is needed to be run for lengthy periods (eg. if a MUD has moved to a different server altogether). Services can only be used on Windows NT. If you need to have the program running constantly on Windows 95, place it in your Startup folder.


How to use
----------

The program reads a configuration file: PORTINFO.CFG

This file must be in the same directory as the PORTINFO.EXE file.

Each line in PORTINFO.CFG specifies a port to be monitored. It consists of a port number, followed by a filename. The filename is the name of a file, whose contents are sent to anyone connecting on that port. Comments may be used, if they start with a # at the start of the line.

eg.

-------------------------------
4201,mushdown.txt
4202,mushdown.txt
# the port below is for a MUD that has relocated
4203,mudrelocated.txt
-------------------------------

You may have any number of ports monitored. Multiple ports may share the same file name, as shown in the example.

The files with the messages in them should be ordinary text files, they will be sent "as is". The contents of the files are loaded into memory when the program starts up. If you change the file contents, you will have to stop PORTINFO and restart it.

Once the program is running, the main thread is waiting on keyboard input. Just press <enter> and the program will wrap up and exit.


How to install as a service
---------------------------

On Windows NT, you can install it as a service. This means it will automatically start up when the system is booted, even if no-one logs in. To do this, use a command prompt window, and type:

PORTINFO /INSTALL
PORTINFO /START

You can subsequently stop it, by typing:

PORTINFO /STOP

To remove the service, type:

PORTINFO /REMOVE

To see if it is running, type:

PORTINFO /STATUS

You can see a summary of commands by typing:

PORTINFO /HELP


Service suggestion
------------------

If you are planning to run PORTINFO as a service, initially test it stand-alone, by typing:

PORTINFO /RUN

That way, any errors in the configuration file (port in use or whatever) will be displayed on the screen. If you get no errors, then go ahead and install it as a service, if that is what you want to do.


Log file
--------

If running as a console application, PORTINFO displays a message for each attempted connection for a port, along with the date and time. The output will look like this:

Starting  listening thread for port 4201...
Connect from: 127.0.0.1 - port 4201 at Wednesday, April 01, 1998, 2:09 PM
Connect from: 127.0.0.1 - port 4201 at Wednesday, April 01, 1998, 2:09 PM
Connect from: 127.0.0.1 - port 4201 at Wednesday, April 01, 1998, 2:09 PM
Connect from: 172.16.10.12 - port 4201 at Wednesday, April 01, 1998, 2:09 PM
Connect from: 172.16.10.12 - port 4201 at Wednesday, April 01, 1998, 2:09 PM

If running as a service, PORTINFO writes to a log file named PORTINFO.LOG. You can check that file periodically to see whether people have been attempting to connect.


Testing the program
-------------------

Once you have the program running successfully, use Telnet (or your MUD client program) to connect to your PC, using the appropriate port number. You can connect to your own PC by connecting to 127.0.0.1 


Fee
---

This program is supplied free of charge. It is copyright 1998 by Nick Gammon. Source code is available upon request. Email: Nick Gammon <nick@gammon.com.au>


Version history
===============

Version 1.01
------------

1. Added a 5-second delay before dropping the connection - this is to make sure the message reaches its destination before being discarded.
2. Now displays the version number when the program starts.
3. Shows the internet name (rather than the IP address) when people try to connect.

Version 1.00
------------

Initial release.

