简体   繁体   中英

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 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.

There are number of ways you can send data over wifi network.

Refer this link:

http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM