How to Transfer Large Files over wifi in iOS

别等时光非礼了梦想. 提交于 2019-12-03 11:20:26

The problem is that your code doesn't loop to gather all of the available data till the end (or loop to send all data either). So you only ever receive the first buffer of data. If the image is small then that works ok, if the image is bigger then it never will.

You need to write the code so that it keeps sending when there is buffer space until all data is sent and keep reading data (into an NSMutableData instance variable, not a local variable) until the end of the stream is reached.

You can use AsyncSocket which can be downloaded from

https://github.com/roustem/AsyncSocket ,

this is an objective-c wrapper build on CFSocket and CFNetwork, it can handle large amount of data transfer with TCP/UDP protocol on local wifi.

You can find the wiki here https://github.com/darkseed/cocoaasyncsocket/wiki/iPhone

The class is very simple and easy to implement.Give it a try

You have make a web service from where you need to put IP address of the system, Where you want to send the file and after that when you can connected with the entered IP address you can send the file in Base64 and NSData format.

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