The Gopher protocol is a document retrieval protocol that pre-dates the Hypertext Transfer Protocol. The advantage that Gopher offers is that it is a simpler, lightweight protocol that doesn’t have the inherent overhead and complexity of a typical HTTP server. It is most commonly used with internal corporate networks to provide access to documents, although its use is less common today than it was several years ago. Unlike some other protocols, where you can connect once and then perform any number of operations, the Gopher protocol requires that you establish a new connection for each request that is made.
Initialize
Initialize an instance of the class, loading the networking library
and validating the development license. This method must be called
before any properties are changed or any other methods in this
class are called by the application.
Connect
Connect to the remote host, using either a host name or IP address.
This method creates the client session and must be called before
your application attempts to request a resource from the
server.
Disconnect
Disconnect from the server and release the memory allocated for
that client session. After this method is called, the client
session is no longer valid.
Reset
Reset the internal state of the component. This can be useful if
your application wishes to discard any settings made by a user and
return that instance of the class to its default state.
Uninitialize
Unload the networking library and release any resources that have
been allocated for the current process. This is the last method
call that the application should make prior to terminating. This is
only necessary if the application has previously called the
Initialize method.
Documents and other resources on a Gopher server are referred to as "items", where an item may be a text file, an executable program or even something that isn't a file at all, such as a Telnet session to a remote host. An item may also be a directory or index of other items. Gopher servers store and return items in a hierarchical fashion, similar to how folders can contain files and other folders, which in turn may contain files and folders of their own and so on.
Every item returned by a Gopher server is identified by a string called its selector. By convention, the item selector is typically a path to the resource on the server; however the only requirement is that the selector be unique for each resource. On some servers the selector may be a file path, and on other servers it may be a number that specifies an index in a database table. Gopher items are also identified by their assigned type, with codes used to identify different types of resources such as text files, HTML documents, image files, executable programs and so on.
Select
This method is used to retrieve an item from the server by
providing the item type and its selector string. If the item type
is a directory or index, then the server will return a list of
those items that it contains. If the item type is a file, then the
server will return the contents of the file to be read by the
client. The first thing an application should do after connecting
to the server is to call this method and specify an item type of
GopherItem.itemDirectory and an empty selector string. This
instructs the server to return the top-level directories and items
available to the client. Using this list, the client can then
select additional subdirectories to navigate through the item
hierarchy.
GetItem
This method transfers an item from the remote host to the local
system, storing the data in memory. This can be useful if your
application needs to perform some operation based on the contents
of the item, but does not need to store it locally. This method can
only be used with file-based resources on the Gopher server. For
example, you cannot use this method with a GopherItem.itemTelnet
item because it represents a Telnet session, not a file.
StoreItem
This method transfers an item from the remote host and stores it in
a file on the local system. As with the GetItem method, this method
can only be used with file-based resources on the Gopher
server.
OnItemList
This event is generated when a directory listing of resources is
requested from the server using the Select method. In order to
process a list of items on the Gopher server, your application
should include a handler for this event, and then store the
returned items in an array or list.