Skip to content

Instantly share code, notes, and snippets.

@tsujp
Last active August 29, 2015 14:21
Show Gist options
  • Save tsujp/c617db3ac405fccfa50f to your computer and use it in GitHub Desktop.
Save tsujp/c617db3ac405fccfa50f to your computer and use it in GitHub Desktop.
// Network Packet Struct
typedef struct {
int fd;
struct sockaddr_in cli_addr;
int length;
char buffer[];
} NET_PACKET;
void receive_payload( int fd, struct sockaddr_in cli_addr, char buffer[], int length ) {
NET_PACKET *packet = malloc( sizeof packet + length + 1 );
if( packet == NULL ) {
printf( "failed.\n" );
exit( EXIT_FAILURE );
}
memcpy( packet->buffer, buffer, strlen( buffer ) + 1 );
receive_nonce( *packet );
}
void receive_nonce( NET_PACKET packet ) {
printf( "Received nonce %s\n", packet.buffer );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment