Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

objective c - Transfer files between 2 iPhones over wifi?

I've spent a few days looking for different solutions, but the whole area is quite complicated, and I'm wondering if anybody knows of any project where I can simply transfer NSData or an NSString or some other simple file over wifi to another iPhone on the network?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Np. Use bonjour to search for devices. Then use CocoaAsyncSocket to send and receive data. It works like a charm.

Little info about AsyncSock:

GCDAsyncSocket and AsyncSocket are TCP/IP socket networking libraries. Here are the key features available in both:

Native objective-c, fully self-contained in one class. No need to muck around with sockets or streams. This class handles everything for you.

Full delegate support Errors, connections, read completions, write completions, progress, and disconnections all result in a call to your delegate method.

Queued non-blocking reads and writes, with optional timeouts. You tell it what to read or write, and it handles everything for you. Queueing, buffering, and searching for termination sequences within the stream - all handled for you automatically.

Automatic socket acceptance. Spin up a server socket, tell it to accept connections, and it will call you with new instances of itself for each connection.

Support for TCP streams over IPv4 and IPv6. Automatically connect to IPv4 or IPv6 hosts. Automatically accept incoming connections over both IPv4 and IPv6 with a single instance of this class. No more worrying about multiple sockets.

Support for TLS / SSL Secure your socket with ease using just a single method call. Available for both client and server sockets.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...