How can i pass NSData object over Wifi network?
How can i pass NSData object over Wifi network? can any one provide me the code to send and receive the NSData 开发者_JAVA百科over Wifi.or any sample code/app reference .
Assuming that you know how to send data in general, here is the code:
uint8_t *bytes = (uint8_t)[myData bytes];
size_t length = [myData length];
sendBytesWithLength(bytes, length);
On the receiver side you regenerate your NSData object like this:
uint8_t *bytes = ; // Get the bytes from somewhere...
size_t length = ; // And the length
NSData *data = [[NSData alloc] initWithBytes:(const void *)bytes length:length];
Have you tried looking at the Bonjour references in the first place to set up the connection? That should lead you on to the other options for network communication.
精彩评论