Microsoft DirectX 8.1 (Visual Basic) |
Establishes the connection to the server. After a connection is established, the communication channel on the object is open and active and the application should expect messages to arrive immediately. No messages can be sent by means of the DirectPlay8Peer.SendTo method until the connection has completed.
Before this method is called, it must obtain an application description by calling DirectPlay8Peer.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.
Although the application GUID is not required, Microsoft® DirectPlay® performs verification if one is specified.
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, after 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 Long, _ UserData As Any, _ UserDataSize As Long) As Long
Returns the asynchronous handle for this operation. This is the handle that is used in lAsyncHandle parameter of the DirectPlay8Peer.CancelAsyncOperation method to cancel the request, if the request is processed asynchronously.
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 |
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 DirectPlay8Peer.Connect is called while another connection is in progress, the function raises an error.
After a call to DirectPlay8Peer.Connect succeeds, all outstanding enumerations are canceled with the DPNERR_USERCANCEL error value set.