void CMonitorData::send(UdpConnection *con,short & sequence,short msg,char *data )
{
int len;
int size;
char *p;

	size = strlen(data)+1;
	p = (char *)malloc(size+6);
	len = 0;
	packShort(p+len, len, msg);
	packShort(p+len, len, m_sequence);
	packShort(p+len, len, size);
	memcpy(   p+len, data, size );
	con->Send(cUdpChannelReliable1, p, size + 6);
	free(p);
	sequence++;
}
Exemple #2
0
int preparePacket(uint8_t *binary, DPlayPacket *packet)
{
    uint16_t offset = 0;

    offset = packShort(binary, packet->size, offset);

    offset = packShort(binary, packet->dplay_id, offset);

    memcpy(binary + offset, packet->sa, sizeof(struct sockaddr_in)); 
    offset += sizeof(struct sockaddr_in);

    memcpy(binary + offset, packet->action, 4);
    offset += 4;

    offset = packShort(binary, packet->type, offset);

    offset = packShort(binary, packet->version, offset);

    memcpy(binary + offset, packet->data, packet->data_size);

    return 0;
}