开发者

How can i pass NSData object over Wifi network?

开发者 https://www.devze.com 2023-03-08 04:14 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号