Microsoft DirectX 8.1 (Visual Basic)

DirectPlay8Client.Connect

Establishes the connection to the server. Once a connection is established, the communication channel on the interface is open and active and the application should expect messages to arrive immediately. No messages can be sent by means of the DirectPlay8Client.Send method until the connection has completed.

Before this method is called, you can obtain an application description by calling DirectPlay8Client.EnumHosts. The EnumHosts method returns a DPN_APPLICATION_DESC type for each hosted application. The type describes the application, including the GUID of the application.

When the connection to the host is requested, the DirectPlay8Event.IndicateConnect method is called in the host's message handler. The host may either accept or reject the connection. In either case, once the host has acted, the client message handler's DirectPlay8Event.ConnectComplete method will be called to convey the response.

Connect(AppDesc As DPN_APPLICATION_DESC, _
    Address As DirectPlay8Address, _
    DeviceInfo As DirectPlay8Address, _
    lFlags As CONST_DPNOPERATIONS, _
    UserData As Any, _
    UserDataSize As Long) As Long

Parts

AppDesc
DPN_APPLICATION_DESC type that describes the application. The only member of this type that you must set is the guidApplication member. Only some of the members of this type are used by this method. The only member that you must set is guidApplication. You can also set guidInstance, pwszPassword, dwFlags, and dwSize.
Address
Optional DirectPlay8Address object that specifies the addressing information to use to connect to the computer that is hosting.
DeviceInfo
DirectPlay8Address object that specifies the network adapter (that is, NIC, modem, and so on) to use to connect to the server.
lFlags
Flag from the CONST_DPNOPERATIONS enumeration that describes the connection mode. You can set the following flag.
DPNOP_SYNC

Process the connection request synchronously. Setting this flag does not generate a DirectPlay8Event.ConnectComplete method call.

UserData
Application-specific user data.
UserDataSize
Size of the data contained in the UserData parameter.

Return Values

Returns the asynchronous handle for this operation. This is the handle that is used in lAsyncHandle parameter of the DirectPlay8Client.CancelAsyncOperation method to cancel the request, if the request is processed asynchronously.

Error Codes

If the method fails, Err.Number can be set to one of the following values.

DPNERR_NOCONNECTION
DPNERR_INVALIDPASSWORD
DPNERR_INVALIDFLAGS
DPNERR_INVALIDINTERFACE
DPNERR_INVALIDAPPLICATION
DPNERR_NOTHOST
DPNERR_SESSIONFULL
DPNERR_HOSTREJECTEDCONNECTION
DPNERR_INVALIDINSTANCE

Remarks

Although multiple enumerations can be run concurrently, and can be run across the duration of a connection, only one connection is allowed per object. To establish a connection to more than one application, you must create another object. That is, only one running application per object is allowed. If DirectPlay8Client.Connect is called while another connection is in progress, the method raises an error.

After a call to DirectPlay8Client.Connect succeeds, all outstanding enumerations are canceled with the DPNERR_USERCANCEL error value set.