To send data/* * * */
Bool CSocketEngine: : send (int main, int sub, void * data, int dataSize)
{
if (! IsAlive ())
return false;
Cocos2d: : log (" SEND - the main command % s % d, % d, sub command % d ", url1. C_str (), port1, main and sub);
//structure data
Unsigned char cbDataBuffer [SOCKET_TCP_BUFFER];
CbDataBuffer TCP_Head * pHead=(TCP_Head *);
PHead - & gt; CommandInfo. WMainCmdID=the main;
PHead - & gt; CommandInfo. WSubCmdID=sub;
If (dataSize & gt; 0)
{
Memcpy (pHead + 1, data, dataSize);
}
//encrypted data
Unsigned short wSendSize=EncryptBuffer (cbDataBuffer, sizeof (TCP_Head) + dataSize, sizeof (cbDataBuffer));
MSocket. Send ((const char *) cbDataBuffer wSendSize);
return true;
}