Sign in to follow this  

DirectPlay - Bad data transmition

Recommended Posts

Hi all... I've been trying to establish a peer-2-peer connection using DirectPlay for a simple console sample game. So, I need to send a message to the other computer, everytime a player made its move. This message is an array of 4 chars. I'm sending it w/ DirectPlay's SendTo function, which looks like this:
                                    phAsync, DPNSEND_PRIORITY_HIGH | DPNSEND_GUARANTEED | DPNSEND_NOLOOPBACK)))

But when I receive it in the other computer, the msg is filled with zeros. I'm receiving the message through the DirectPlayMessageHandler, which is the following:
        case DPN_MSGID_RECEIVE:
            PDPNMSG_RECEIVE     pMsg;
            TCHAR       strBuffer[4];

            pMsg = (PDPNMSG_RECEIVE) pMsgBuffer;
            DXUtil_ConvertWideStringToGenericCch( strBuffer, (WCHAR*) pMsg->pReceiveData, 4);

			for (int i = 0; i < 4; i++)
				//Avoid garbage
				if (strBuffer[i] >= 0)
					msg[i] = strBuffer[i];
                        //Check it up
			cout << msg[0] << msg[1] << msg[2] << msg[3] << endl;

Can someone tell me why this happens? What am I doing wrong here? =S Thanks everyone...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this