I want to make an iPhone app and an application (server) which runs on a PC with Windows. Is there any easy way to do this on the client side (the iPhone), like a library or something?
Looking on Google I found cocoaasyncsocket and xmppframework, but the last commits were done some time ago and before I start my project I want to know if there are other (better) possibilities out there
One option would be to run a web server on the PC, with a set of REST-based services. This approach gives you lots of options for implementation on the server-side, and you'll have lots of possible frameworks to choose from on the client-side as well. One framework you could use on the iPhone is ASIHTTPRequest.
There are lots of advantages to using a web-based approach. There are HTTP frameworks built for almost every device and platform, so if you ever want to interact with the server from the web, an Android device, etc., there will be many tools to help you do that. There are also lots of great tools out there for debugging HTTP interactions.
You could also use a SOAP-based API, but in my opinion SOAP tends to be more complicated than its worth.
Related
I'd like to play with the idea of creating a server program that communicates with an iPhone app over socket connections. I've found several guides within Apple's documentation for client side programming (with CFNetwork, NSStream, etc) but I don't know where to begin on programming the server application, or even what language to use, or for that matter, how to deploy and run a server application on my current web hosting package through Go Daddy. A simple instant messenger style application example should get me started, but any advice is appreciated.
if you want to create socket connection is better to use CFNetwork , it has more flexibility for you I already used NSURLConnection but CFNetwork has better performance. this is my steps and how I developed my app :
configuration of server
selection C++ for my server side (service)
start to develop a client-side app for iphone to connect to server using NS classes
but I had some problems in sending and receiving message to and form server . so I changed it to CF classes it works better and faster now.
The easiest way to handle server-to-device communications is to use APNS (Apple Push Notification Services).
Communication in the other direction (device-to-server) can be handled simply with NSUrlConnection.
If you want to write your own socket code for this, well - good luck with that.
Do you want your client application to be able to run on more than one OS? If so, you might want to stay clear of anything Apple specific. Although, if you strictly want to run on iOS, using MusiGenesis' suggestion could save you a ton of time.
I have found that Python and Perl are both pretty great for socket programming. I know that Python has several libraries built in for handling HTTP requests etc. If you want to run your server as a daemon, I found this code very helpful:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
Here is a general python sockets guide:
http://docs.python.org/howto/sockets.html
Good luck.
I am keen to get some apps built that can communicate with other devices/ web etc. i have played around with FTP and can get so far. But what is the best way to do this? We don't have any Servers with databases etc, but do have a site that we are currently uploading and downloading files to.
can anyone suggest a good/ better way to get the device to send/ receive files?
thanks
sam
If it's HTTP communication you're wanting to do, the simplest and most powerful tool is ASIHTTPRequest.
HTTP is the protocol your web browser uses to talk to web servers. If you have a site you're storing and downloading files at, it's almost certainly HTTP you're talking to it.
For iOS device to device communication one can use Bump API.
EDIT: I don't know of a generic framework for device <-> server communications, but having built applications that use web services of other providers like Yelp, Yahoo, Google Maps, I would say the way to go for this is to have REST based web services which exchange data in JSON format.
Based on a college-project I'm trying to realize a relatively simple game (Poker) where an iPad acts as Server and multiple iPod-Touchs connect to it as Clients.
Gamekit seems to drop out, since those old ipod-touch-devices don't have bluetooth-support.
Are there already some Frameworks out there simplifying the process, or do I have to fall back on TCP-Streaming-Sockets and implement it myself?
For your task I suggest you have a look at ThoMoNetworking or AsyncSocket.
ThoMoNet is a very simple setup that is specifically developed for fast and easy prototyping and easy to set up. Is will automatically create a bi-partite graph between all instances of you application it finds in the local network. So If you keep your iPad as the server and the iPhones as clients this will come down to less than 10 lines of code to set up.
AsyncSocket is a commonly used framework with ports to PC as well but requires more code to write. On the other hand it will allow you to do more fancy things, should you need them.
Distributed objects are not yet available on iPhone OS, so excluding GameKit you may try using Bonjour networking. Otherwise, you may try using web services with some of the available libraries. If Bonjour and web services are not a choice/possibility, then you have to revert to old plain sockets.
Aplogies for the ignorant question, I have no experience with app development on any mobile platform. Basically what I want to know is what communication protocols do apps typically use for accessing/querying centralised services? E.g if I port a webapp/service to iPhone/Android, typically how would I access/query this web service in my app? E.g is it over HTTP, or are there other protocols?
Also, presumably the GUI of an app is constructed with Apple/Android GUI libraries (in java? cocoa?). Can an app GUI be defined with HTML/javascript like a webpage?
Sorry again for the pure noob questions.
Thanks
Your question is pretty broad as you can really implement it however you want, but in my own experience the majority of "centralized" services are accessed directly over HTTP using an HTTP networking library or NSURLConnection. Most of the web services I work with are RESTful. Some people might implement with straight sockets, but that's just pain and would be best avoided if possible.
The GUI side is done using Cocoa Touch on the iPhone. I'm not sure about Android. You can certainly implement a web based app targeted specifically for iPhone. In fact there's been a lot in the news lately about developing HTML5 apps for the iPhone and iPad.
Can you anyone point me to specific books or maybe give me a quick overview of how architectures of data-driven iPhone applications look like? For example, let's say you're implementing an application that searches online shopping sites and gives you recommendations..etc. Is it a common pattern to establish a hosted back-end of webservices which does all the database/shopping site API connections/webservices work and have the iPhone app consume services on this backend? or do you put everything in the iPhone application? Also, if you are establshing a web-services back-end, is it better to use REST/JSON vs REST/XML vs SOAP/XML...etc?
Thanks
To answer the first part of your question, I'd say that's up to you. If there's a lot of processing that needs doing between the web service and the iPhone, then maybe you should have your own backend server doing that processing before sending it to the iPhone. However, if you just need the data from the web service as-is on the iPhone, then just consume it directly.
As for the different formats, with the iPhone smaller is always better when it comes to network traffic. Stick with using REST for sure so you minimize data that needs to be transferred from the iPhone. As for JSON vs XML, obviously JSON is more lightweight which makes it a better candidate for the iPhone generally, but if your data requires a representation more complex than JSON can offer, then go with XML. Don't do SOAP if you can at all avoid it. It's just too heavyweight and will drain the iPhone's battery much more quickly with many requests.
If you are curious about the architecture and implementation details of a data-driven iPhone app, take a look at all of Apple's docs and tutorials about Core Data on the iPhone.