如何通过wifi从iphone发送数据到应用程序,打印消息
我想知道如何执行以下操作:
i would like to know how to do the following:
第1步:如何将以下字符串从iphone发送到当用户按下按钮时,通过WIFI使用mac计算机。
step 1: how to send the following string from the iphone to a mac computer via WIFI when a user presses a button.
要发送的字符串:hello。
string to be sent: "hello".
step2:如何使用我必须创建的应用程序接收该字符串。这将非常简单。它将没有界面,除了它只打印出消息。
step2: how to receive that string with an application i would have to create. it will be very simple. it will have no interface, except it will just print out the message.
我如何实现这样的目标。我从未使用iphone编程通过WIFI发送信号。有人可以指导我吗?
How do i achieve something like this. I've never sent a signal over WIFI with the iphone programming. Can someone guide me please?
我会引用一个类似的问题:
I'll quote myself from a similar question:
如何创建一个从iOS应用程序通过WiFi网络接收数据的小型Mac应用程序?
使用CFNetwork框架,您可以使用bonjour进行发现,然后通过本机套接字来处理持久连接,以便来回传递数据。
Using the CFNetwork framework, you can use bonjour for discovery and then handle a persistent connection through native sockets for passing data back and forth.
这是一个很好的入门教程,适用于iOS,但CFNetwork也可以在OS X中使用。
Here is an excellent tutorial to get started, its for iOS but CFNetwork is available in OS X too.
http://mobileorchard.com/tutorial-networking-and-bonjour-on-iphone