[iPhone]: How send output stream via wireless network?

此生再无相见时 提交于 2019-12-06 15:11:50

问题


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?

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


回答1:


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

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



来源:https://stackoverflow.com/questions/1187031/iphone-how-send-output-stream-via-wireless-network

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!