Another critical part of the networking toolkit is the Connector
class. This class has only a few static members and acts as a factory for all of the Connection
types. The networking that we will be doing is of course one of these, but there are, in fact, many kinds of connections that can be made through the Connector
class. This class is very flexible because the open
method takes only one parameter—a connection string.
It may seem funny but the Connector
class doesn't actually initiate a connection. It simply creates an object that represents the connection. The Connection
object does the actual work of opening the connection sometime later when it needs to do so. Therefore, the Connector
won't fail unless the connection string is invalid in some way.
A connection string is also called a URL but it is more than just an address like you might think of when web browsing. It can also contain all of the instructions and options that the Connection
class might need in order...