Created
December 6, 2013 09:43
-
-
Save icanswiftabit/7821120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sender | |
NSData *data2 = [self createRandomNSData:8192]; | |
NSMutableData *dataToSend =[NSMutableData data]; | |
[dataToSend appendBytes:&tag length:sizeof(int)]; | |
float currentTimeStamp = CACurrentMediaTime(); | |
[dataToSend appendBytes:¤tTimeStamp length:sizeof(float)]; | |
[dataToSend appendData:data2]; | |
NSLog(@"%i || %f || %lu",tag, currentTimeStamp,(unsigned long)[dataToSend length]); | |
[_udpSocket sendData:dataToSend toHost:@"230.0.0.1" port:_port withTimeout:-1 tag:tag]; | |
tag++; | |
//reciver | |
char* dataBytes = [data bytes]; | |
int inTag; | |
float inCurrentTimeStamp; | |
[data getBytes:&inTag length:sizeof(int)]; | |
[data getBytes:&inCurrentTimeStamp range:NSMakeRange(sizeof(int), sizeof(float))]; | |
float currentTimeStamp = CACurrentMediaTime(); | |
float timeStampDiff = currentTimeStamp - inCurrentTimeStamp; | |
NSLog(@"%i || %f || %lu",inTag, timeStampDiff,(unsigned long)[data length]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment