简体   繁体   English

我如何通过 Wifi 网络传递 NSData object?

[英]How can i pass NSData object over Wifi network?

How can i pass NSData object over Wifi network?我如何通过 Wifi 网络传递 NSData object? can any one provide me the code to send and receive the NSData over Wifi.or any sample code/app reference.任何人都可以向我提供通过 Wifi 发送和接收 NSData 的代码吗?或任何示例代码/应用程序参考。

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:在接收端,您像这样重新生成 NSData object:

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?您是否尝试过首先查看 Bonjour 引用来建立连接? That should lead you on to the other options for network communication.这应该会引导您使用其他网络通信选项。

There are number of ways you can send data over wifi network.您可以通过多种方式通过 wifi 网络发送数据。

Refer this link:参考这个链接:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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