Skip to content

Instantly share code, notes, and snippets.

@dennda
Created September 13, 2011 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennda/1212964 to your computer and use it in GitHub Desktop.
Save dennda/1212964 to your computer and use it in GitHub Desktop.
Send & Receive
// Send:
const uint8_t query = (uint8_t)USERNAME_QUERY;
const uint8_t length = (uint8_t)sizeof(query);
[stream write:&length maxLength:sizeof(uint8_t)];
[stream write:&query maxLength:length];
// Receive:
uint8_t length;
[inStream read:&length maxLength:sizeof(uint8_t)];
uint8_t buffer;
[inStream read:&buffer maxLength:(uint)(length)];
LOG_NETWORK(8, @"Read %d bytes. Content: '%s'", (int)(length), (char*)buffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment