c++ - Could openframeworks udp manager only receive char[]? -
i programme using openframeworks addons udpmanager.
the illustration code in udp receiver side this:
void ofapp::update() { char udpmessage[1000]; udpconnection.receive(udpmessage,1000); string message=udpmessage; } but if want send byte[] (not using udp sender, using other language), receive u_int8[] or int[]?
short answer: yes, could. here how.
all have map udpmessage, of type char u_int8[] or int[]
uint8_t *destinationarray = null; destinationarray = (uint8_t*)&udpmessage; this works because mapping location in memory of udpmessage, interpreting array of uint8_t. can utilize subscript operator [] on destinationarray, however, sure check out-of-bounds.
alse, careful, memory mapping sensitive type sizes. if size of char different uint8_t on implementation, cause info mapped incorrectly.
c++ openframeworks
No comments:
Post a Comment