[iPhone]:如何通过无线网络发送输出流? [英] [iPhone]: How send output stream via wireless network?

查看:68
本文介绍了[iPhone]:如何通过无线网络发送输出流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为某种类型的打印机编写一个应用程序,以便通过iPhone的wifi打印一些文本. iPhone可以通过设置"应用程序加入现有的wifi网络,但是如何为该网络创建输出流,以便该应用程序可以使用它向打印机发送命令?

I want to write an app for a certain type of printer to print some text via wifi for iPhone. iPhone can join an existing wifi network by the Settings app, but how to create an output stream for the network so that the app can use it to send command to printer?

我的意思是已经建立了wifi连接,如何获取类似于NSOutputStream的数据来向其中写入数据?

I mean the wifi connection is set up already, how to get something like NSOutputStream to write data to it?

推荐答案

我不确定您的wifi打印机使用什么协议(或一般而言的wifi打印机),但是您很幸运,可以编写iPhone应用程序来与网络.您可以使用低级BSD Unix风格的网络套接字调用,但是幸运的是,您不必这样做. CFNetwork将在这里成为您的朋友.

I'm not sure what protocal you wifi printer uses (or wifi printers in general) but you are in luck, iPhone apps can be written to interact with the network. You could use the low level BSD Unix style network socket calls, but luckily`you don't have to. CFNetwork will become your friend here.

CFNetwork CFNetwork是Core Services框架中的一个框架,它为网络协议提供了一个抽象库.这些抽象使执行各种网络任务(包括使用流)变得容易.

CFNetwork CFNetwork is a framework in the Core Services framework that provides a library of abstractions for network protocols. These abstractions make it easy to perform a variety of network tasks including working with streams.

我建议在以下位置阅读《 CFNetwork编程指南》: http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/CFStreamTasks/CFStreamTasks.html#//apple_ref/doc/uid/TP30001132-CH6-SW1

I recommend reading the CFNetwork Programming Guide at: http://developer.apple.com/documentation/Networking/Conceptual/CFNetwork/CFStreamTasks/CFStreamTasks.html#//apple_ref/doc/uid/TP30001132-CH6-SW1

这篇关于[iPhone]:如何通过无线网络发送输出流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆