Salut,
Jusque la tout allait bien, mais sur ce coup la je vais craquer ^_^' ... je vous expose mon probleme.
je cree 1 client et 1 serveur TCP IP.
J'host le server, ca me renvoie un HRESULT qui faut S_OK, pas de probleme tout va bien... detail du code par ici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 CoInitialize(NULL); CoCreateInstance( CLSID_DirectPlay8Server, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Server, (LPVOID*)&ds); ds->Initialize( NULL , DPlayMessageMap , 0 ); CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&deviceaddress); deviceaddress->SetSP( &CLSID_DP8SP_TCPIP); DPN_PLAYER_INFO playerinfo; WCHAR wservername[256]; DXUtil_ConvertGenericStringToWide( wservername, "LESERVEUR" ); ZeroMemory( &playerinfo, sizeof(DPN_PLAYER_INFO)); playerinfo.dwSize = sizeof(DPN_PLAYER_INFO); playerinfo.dwInfoFlags = DPNINFO_NAME; playerinfo.pwszName = wservername; hr = ds->SetServerInfo(&playerinfo,NULL,NULL,DPNSETSERVERINFO_SYNC); if( FAILED( hr ) ) { return hr; } // APPLICATION_DESC DPN_APPLICATION_DESC appdesc; DWORD dwPort = 9000; WCHAR wsessionname[256]; DXUtil_ConvertGenericStringToWide( wsessionname, "LaSession" ); ZeroMemory( &appdesc, sizeof(DPN_APPLICATION_DESC) ); appdesc.dwSize = sizeof(DPN_APPLICATION_DESC); appdesc.guidApplication = LEGUID; appdesc.pwszSessionName = wsessionname; appdesc.dwMaxPlayers = 0; appdesc.dwFlags = DPNSESSION_CLIENT_SERVER; hr = deviceaddress->AddComponent(DPNA_KEY_PORT,&dwPort,sizeof(DWORD), DPNA_DATATYPE_DWORD); if( FAILED( hr ) ) { return hr; } hr = ds->Host( &appdesc, &deviceaddress,1,NULL,NULL,NULL,NULL );
Puis je lance mon client, et la probleme, il me renvoie sur le "connect()" un HRESULT valant 1409038 (non reference chez msdn)... le code idem :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 CoInitialize(NULL); CoCreateInstance( CLSID_DirectPlay8Client,NULL,CLSCTX_INPROC_SERVER,IID_IDirectPlay8Client,(LPVOID*)&dc); dc->Initialize( NULL , DPlayMessageMap , 0 ); CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&deviceaddress); deviceaddress->SetSP( &CLSID_DP8SP_TCPIP); CoCreateInstance( CLSID_DirectPlay8Address, NULL, CLSCTX_INPROC_SERVER, IID_IDirectPlay8Address, (LPVOID*)&hostaddress); hostaddress->SetSP( &CLSID_DP8SP_TCPIP); DPN_PLAYER_INFO playerinfo; WCHAR wpeername[256]; DXUtil_ConvertGenericStringToWide( wpeername, "LeClient"); ZeroMemory( &playerinfo, sizeof(DPN_PLAYER_INFO) ); playerinfo.dwSize = sizeof(DPN_PLAYER_INFO); playerinfo.dwInfoFlags = DPNINFO_NAME; playerinfo.pwszName = wpeername; hr=dc->SetClientInfo( &playerinfo, NULL, NULL, DPNSETCLIENTINFO_SYNC ); DPN_APPLICATION_DESC appdesc; WCHAR hostname[256]; ZeroMemory( &appdesc, sizeof( DPN_APPLICATION_DESC ) ); appdesc.dwSize = sizeof( DPN_APPLICATION_DESC ); appdesc.guidApplication = LEGUID; appdesc.dwFlags=DPNSESSION_CLIENT_SERVER; WCHAR wsessionname[256]; DXUtil_ConvertGenericStringToWide( wsessionname, "LaSession" ); appdesc.pwszSessionName = wsessionname; DXUtil_ConvertGenericStringToWide( hostname, "127.0.0.1" ); hr=hostaddress->AddComponent(DPNA_KEY_HOSTNAME,hostname,(wcslen(hostname)+1)*sizeof(WCHAR),DPNA_DATATYPE_STRING); DWORD dwPort; dwPort=atol("9000"); hr=hostaddress->AddComponent(DPNA_KEY_PORT,&dwPort,sizeof(DWORD),DPNA_DATATYPE_DWORD); hr=dc->Connect( &appdesc,hostaddress,deviceaddress,NULL,NULL,NULL,0,NULL,&ConnectAsyncOp,NULL);
Voila en gros mon soucis, comment faire pour que ce foutu client se connecte ? ^_^ je craque
ps: j'ai lu sur le journal d'un prog trouve sur le net une idee comme quoi il faut faire une copie complete des hostaddress/deviceaddress entre le client et le serveur, mais bon c'est a peu pres ce que j'ai fait ...
pps: les GUID entre client et serveur sont identiques, c'est correct ?
merci d'avance..
edit : l'erreur est "1409038 = DPNSUCCESS_PENDING" ... cela voudrait il dire qu'en fait je suis connecte ? pourtant mon serveur ne recoit aucun message de connection![]()
Partager