DirectPlay help...or maybe simpler?

This is a discussion on DirectPlay help...or maybe simpler? within the Windows Programming forums, part of the Platform Specific Boards category; I have been trying to learn DirectPlay with the assistance of MSDN and the source code bundled with the directX ...

  1. #1
    Registered User
    Join Date
    Feb 2003

    Unhappy DirectPlay help...or maybe simpler?

    I have been trying to learn DirectPlay with the assistance of MSDN and the source code bundled with the directX 8.1 SDK.

    Problem: Connection works fine, server successfully retrieves client data, but in the following attempt to send a welcome message from the server, the output on the client's side is "Server Sent: " instead of "Server Sent: Welcome to the Server!" I've been going over my code over and over again.. I am pretty sure directplay is not the problem, more likely I've lost something essential in the conversion of and output of data.

    Related code in header file included in both server and client program:

    #define MAX_CHAT_LENGTH 40

    DWORD dwType;

    CHAR strBroadcast[MAX_CHAT_LENGTH]; // message to be sent

    Code in server program:

    GAMEMSG_BROADCAST msgBroadcast;
    msgBroadcast.dwType = GAME_MSGID_BROADCAST;
    strcpy (msgBroadcast.strBroadcast,"Welcome to the Server!");
    DPN_BUFFER_DESC bufferDesc;
    bufferDesc.dwBufferSize = sizeof(GAMEMSG_BROADCAST);
    bufferDesc.pBufferData = (BYTE*) &msgBroadcast;

    g_pDPServer->SendTo( dpnidNewPlayer, &bufferDesc, 1,

    Code in client program:

    PDPNMSG_RECEIVE pReceiveMsg;
    pReceiveMsg = (PDPNMSG_RECEIVE)pMsgBuffer;

    GAMEMSG_GENERIC* pMsg = (GAMEMSG_GENERIC*) pReceiveMsg->pReceiveData;
    switch( pMsg->dwType )

    // We're getting a text message from the server
    GAMEMSG_BROADCAST* pBroadcastMsg;
    pBroadcastMsg = (GAMEMSG_BROADCAST*)pReceiveMsg->pReceiveData;
    printf("\nServer Sent: %S\n", (CHAR *) pBroadcastMsg->strBroadcast);


    Now, I know that the data is sent. By adding in some debug code, I find that the above case IS triggered. However, all that is outputted is "Server Sent: " Other types of communication between the two programs have been successful, but I cannot get this one to work. What am I missing? What's wrong? I appreciate the help in advance!
    Last edited by Trireme; 02-14-2003 at 05:59 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectPlay or Winsock?
    By kevinawad in forum Networking/Device Communication
    Replies: 5
    Last Post: 10-20-2008, 07:12 PM
  2. DirectPlay & a DirectX question
    By Lurker in forum Game Programming
    Replies: 2
    Last Post: 02-24-2004, 04:37 PM
  3. OOP for DirectPlay Peer to Peer program
    By curlious in forum Networking/Device Communication
    Replies: 0
    Last Post: 11-03-2003, 11:21 PM
  4. DirectPlay?
    By Mecnels in forum Windows Programming
    Replies: 1
    Last Post: 04-07-2003, 09:07 AM
  5. mulitplayer and directPlay
    By phantom in forum Linux Programming
    Replies: 1
    Last Post: 03-28-2002, 11:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21