Skip to content

ZosConnectionLock

In a server application, there may be a requirement to have more than one user ID logged onto the same server at the same time. You can accomplish this by using alternate connections to the server. Each server can have alternate connections, with connection IDs numbered 1 – 255. The default connection has a connection ID of 0.

The ZosConnectionLock class can be used to reserve a connection ID, and lock the connection ID so that it will not be used by other programs or threads. The default connection ID, 0, will never be locked.

With ZosConnectionLock you can either implicitly lock a connection ID via the constructor or you can explicitly lock a connection ID by calling the Lock method.

You must unlock the connection ID by calling either the Unlock or Dispose method of ZosConnectionLock. With C# and Visual Basic, you can have the connection automatically unlocked by using a using statement. With C++, you can have the connection automatically unlocked by declaring the ZosConnectionLock object as a stack variable.

If the connection is not automatically unlocked, then you should ensure that the connection gets unlocked, by explicitly unlocking it in the finally block of a try / finally construction.

For more information on the usage of ZosConnectionLock, see the section entitled Alternate Connections.

ZosConnectionLock Constructor

The following constructor can be used to initialize a new ZosConnectionLock object:

Constructor Parameters
ZosConnectionLock( String name, Boolean locked [optional] ) name: Server name for which a connection is to be locked locked: Indicates connection is to be initially locked

ZosConnectionLock Properties

ZosConnectionLock exposes the properties below. All properties are read only.

Property Type R/W Description
Name String R Name of the server for which a connection is to be locked.
Connection Int16 R Connection ID that has been locked or zero if no connection is locked.

...

ZosConnectionLock Methods

ZosConnectionLock exposes the following methods:

Dispose() Method

Releases the connection ID that was previously locked and destroys the lock. Object cannot be used again after calling Dispose().

void Dispose()

Lock() Method

Obtains and locks a connection ID. Returns the connection ID.

Int16 Lock()

Unlock() Method

Releases the connection ID that was previously locked.

void Unlock()

ZosConnectionLock Examples

Examples of using ZosConnectionLock are shown in the section entitled Alternate Connections.

Back to top