WiFi iPhone Application - iphone

im working on an iPhone application which requires communication between 2 devices through WiFi.
Can somebody please help me by providing a simple iphone application code for the same which is able to communicate data between the devices...i hv gone through the "witap application" available on the developers site but wasnt able to understand it...
please help..

There's a great 2-part tutorial at MacResearch:
Part One
Part Two

Use the Bonjour , let Device A as the server, and publish service via Bonjour; and in Device B,use the NSNetServiceBrowser to search the published service via device A in the same local network,and connect by socket to send data.
there is a demo here.download.And you can read this article go>>.It helped me before.

Related

Want to test Bonjour with 2 iphone/ipad

Apologies for such a silly question.
Please note I don't have Apple TV or any printer. I would like to get hold of the packet trace that takes place when bonjour (Discovery and Resolution phase) is in action. I need to get bonjour into action using just 2 iphone/ipad (I have a Wifi Network through which I could connect these iPad/iPod). Please suggest what application can I use to achieve this? I am a newbie in iOS world, and have no idea of apps related to bonjour.
Hope some of you could help.

Peer-to-peer communication between iOS devices

I am trying to prototype a solution to a problem and am currently exploring multiple routes I could try. Is it possible for one iOS device, running a certain app, to communicate directly with another iOS device, running the same application - without the need to be on the same LAN?
Solutions I am currently investigating are using Bluetooth and ad-hoc wireless connections.
Ideally, the application when installed would ask the user for the required permissions, and then would accept and/or send data to/from another client after a handshake had happened.
My concern with Bluetooth is that 'pairing' would need to happen with every device, rather than happen in the background once the user has installed the app. I have a feeling what I am talking about isn't possible from what I've been reading elsewhere on Stackoverflow.
Take a look at Bluetooth Low Energy.
https://developer.apple.com/library/ios/#samplecode/BTLE_Transfer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012927
Here is another example,
https://github.com/KhaosT/CBPeripheralManager-Demo
You might also want to look into GameKit and peer-to-peer connectivity there.
I can't tell you anything about it, but you might try looking at iOS 7. If that's an option, I'd take a look. Can't talk about what it is because of NDA though.
Depending on what you need to communicate, you could try checking out this project, which lets you share arrays of strings between iOS devices over Bluetooth LE.
You don't need to "pair" the devices and it can still communicate while the app is in the background. SimpleShare
Hope it helps!
From the documentation of MultipeerGroupChat:
MultipeerGroupChat sample application utilizes the Multipeer Connectivity framework to enable nearby users to discover, connected, and send data between each other. This sample simulates a simple chat interface where up to 8 devices can connect with each other and send text messages or images to each other. Here you will learn how to bring up framework UI for discovery and connections and also how to monitor session state, listen for incoming data and resources, and send data and resources.
This is an excellent example at developer.apple.com here is the link
https://developer.apple.com/library/ios/samplecode/MultipeerGroupChat/Introduction/Intro.html
Also this tutorial from Ralf Ebert demonstrates how to use Multipeer Connectivity framework for peer communication should help you.
https://www.ralfebert.de/tutorials/ios-swift-multipeer-connectivity/

Socket Connection on iPhone

I want to establish socket connection between iphone and a web service that has its own IP address, service name (e.g "_abc._tcp"), and it also contains information about files stored. How can I do this? Can you please help with some sample code or links.
My goal is to develop an application that will get a video file from that server to my iphone and play it.
At first I try to get information of the files but I don't know how to connect to that server and make the video played on my iPhone.
Many thanks in advance
There is a great library for socket programming in objc here CocoaAsyncSocket
Which will help you out a lot. The examples also show how to use NSNetServices to broadcast a Bonjour service.

Communication between two iOS devices

I am looking for a way to have one iPhone app send a message to another app on a different phone (sort of like a Sender-Receiver set up). I am looking for the best possible way to do this. Does anyone have any ideas and/or tutorials?
Thanks for the help.
You should use GameKit. It is super easy to send messages between two iOS devices using it. Here's a great tutorial: Game Kit. You can also get more information about it here from the docs: About Game Kit.
You communicate by creating an ad-hoc bluetooth or local wireless network.
lmirak provided insightful info about device communication(especially about GameKit). I would like to add one more solution. You can use WiFi network to do your device communication.
See the link or download the sample application from developer.apple
The sample application named as WiTap. It demonstrates how to achieve network communication between applications. Using Bonjour, the application both advertises itself on the local network and displays a list of other instances of this application on the network.
If your app is only going to run on iOS, then you should use the fantastic MultipeerConnectivity library. https://developer.apple.com/documentation/multipeerconnectivity
If you need a solution that will work cross-platform, then one way to accomplish this is using sockets and connecting over a local network. On iOS you can use CocoaAsyncPods for sockets and NetService for discovery.
Here is a basic example app that does this: https://github.com/brendaninnis/LocalNetworkingApp
, which I explain in great detail here: http://brendaninnis.ca/connect-nearby-devices-part-1.html

Issue with the wifi in iPad

I am working on a educational related apps. My app functionality is working well when the WIFI is connected otherwise it is getting crashed.
In my app I am connecting with the server using NSURLRequest class its working.
the download also not having any problem if the wifi is available.
problem rectification: I have to know weather the my app device is connected with external network or not.
So, how can I know my app is connected with the wifi or not?
The following link consists source code, in which it consists how to check the reachability. That means the wifi or any network is connected of not.
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
Apple provides sample code called "Reachability" to detect when the network is available. That would be a good starting point, though a quick Google should locate some alternatives.