Running PHP server and MySQL on iOS device - iphone

Is there any possibility of running a PHP server (lighttpd, apache, cherokee, etc) and a MySQL server (or sqlite) on a non-jailbroken iOS device? I know about http://www.becomekodiak.com/ and they seem to be running a server (or just an interpreter?), but there is no database connection.

You could use cocoahttpserver, iPhoneHTTPServer3, SimpleWebSocketServer, MultithreadedHTTPServer3 or MongooseDaemon to realize the Server. The content generation is being made by your code and you could use CoreData or any other mobile database solution to save and provide the data.
It's no PHP, but you could implement it in Objective C.

Related

Data transfer Windows Embedded Compact 7 & Computer VIA USB connection

I made an app using the barcoding for inventory management, now i need to transfer that data to the computer. For this purpose i used TCP/IP Host client sample applications given in windows mobile 6.5.3 SDK samples.
When i run the application its' fine no errors, shows connected to the Host IP but no data is transferred, When i debugged there is no exception code just works fine but there is no functionality performed. My connection is USB connection. IP shown in host application is correct, my device is also having IP (check through ipconfig). Now when i ping my host computer from device, it is giving error
PING: transmit failed, error code 11010
Is my approach right towards this situation using this data transfer over this socket ? If yes then how can i make this connection successful ? If not what is the other solution for this data transfer from device to computer. (software on device is using SQL CE and application on computer is ASP.NET application using SQL Server database.)
I saw various similar questions about this problem but unable to find any suitable solution. PS i am new this platform of windows mobile/embedded
If not what is the other solution for this data transfer from device
to computer. (software on device is using SQL CE and application on
computer is ASP.NET application using SQL Server database.)
These are some common solutions for client/server communications on Windows Mobile:
Use RAPI or RAPI2 to communicate with the mobile device and host PC using the USB ActiveSync/Windows Mobile Device Center connection. You could use this option to export a CSV file from the mobile device to the host PC. Then you can import the CSV file into the host database. Requires physical access to host PC via USB.
Call a web service to transmit the data to the server. You can write a simple RESTful web service using ASP.NET Web API. If you're using C++ you can use WinInet API, but it's kind of painful. If you're using C# then you have built-in support and it's not an issue.
Use SQL CE Replication.

Debugging network connections on the iPad. Any tools or techniques?

I'm trying to get my iPad (3rd gen) to access a website on my workstation over an https connection (though I should perhaps mention I cannot connect to it over HTTP either). The aim is to have a working demo of two-way authentication with certificates.
I've installed the client cert on the iPad and a number of Windows and OSX machines on our network. But the iPad seems to be having trouble getting the IP from the local DNS server or perhaps hitting the DNS server at all. As there doesn't seem to be a Hosts file or any way of debugging the network side of the iPad I'm a bit stuck.
Does anyone have any hints/tips/tools that could make my life half-way bearable?
Unfortunately things like you mention aren't built in in iOS. I would have a look in the App Store and get an app to perform pings and do DNS lookups. Maybe NetTools could work for you?

How to implement node-postgres on a user's browser?

So I've tested this particular example on my local machine:
http://bjorngylling.com/2011-04-13/postgres-listen-notify-with-node-js.html
It worked! So now when I update a specific table, and am running my node.js file(from the tutorial) -I get an instant notification on my Terminal(mac)!! cool!
But how do I implement this onto a client's browser??
First of all, in the node.js script you'll notice that I have to connect to the database with my username and password:
pgConnectionString = "postgres://username:pswd#localhost/db";
I obviously can't have that floating around in the .js file the user's browser downloaded.
Plus I don't even know what scripts I'd have to include in the <head>. I can't find anything anywhere on how this is used in the real world.... All I see are neat little examples you can use in your command line.
Any advice, or guidance in the right direction would be awesome! Thanks.
You can't.
Node.js runs directly on your server, speaking directly to the native libraries on that machine. I'm not sure exactly what the postgres driver you are using does, but either it speaks to the postgres libraries OR it speaks directly with sockets on the local or a remote database server.
Neither of these methods can be used directly from a browser environment (it can't speak directly to the native libraries and it can't speak "raw" sockets).
What you can do is to have the web client speak to your own server process on a server (running node.js or similar), which would then speak to the database on behalf of the client.
Assuming you also need to database server to be able to initiate notifications to the client, you would need to use a bi-directional communication module like socket.io or similar.
You can do: combine your JS running on node.js which accesses Postgres listening for events with a node.js based WebSocket server, implement PubSub and push out to HTML5 browsers .. WebSocket capable ones.
Another option: use a generic WebSocket to TCP bridge like https://github.com/kanaka/websockify and implement the Postgres client protocol in JS to run in browser. That is doable, but probably not easy / for the faint hearted.

How to connect to remote mysql from iphone application?

i am newbie to iphone programming. I am working on an iphone project.
My question is:
How to connect my iphone application to a remote server mysql database directly?
There are many ways to connect through PHP scrip/ json/xml/ webservices.
But i dont need that. I would like to have direct connetion to mysql of remote server without any intermediate?
Basically you would need to build a mysql client lib for iOS and then use that from Objective-C. This blog post should get you started. As stated by peko you should really reconsider that you are doing the right thing. The mysql network protocol isn't exactly made for mobile clients where connections can drop, be unavailable, etc.
You shouldn't do this because someone could sniff the traffic and get the username and password for your database, or inject sql-code.
Here's a MySql objective-C client for iPhone. It was traditionally available only for OSX but they just released it for iOS:
http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/
I haven't used it. I would still strongly recommend exposing via services. I would also be interested in why you need to directly connect to the DB and why services isn't appropriate :)

iOS communicating with OS X

I'm looking for a pointer in the right direction to get started with writing an iPhone app that sends commands to OS X, for example telling OS X to sleep. I can't seem to find the relevant part of the documentation?
AFAIK, most apps have been performing this kind of communication with a client/server design, where a "server" app runs on the host OS X machine, and a "client" app on the iOS device connecting using some sort of protocol (HTTP? Bonjour?).
You won't find this in the documentation because this is a niche design pattern that few apps need (especially since documents can now be shared more easily with the new version of iOS and iTunes).
iOS doesn't support ObjC remote objects, which would be the easiest way to communicate between two OS X machines.
An alternative to the HTTP client/server approach could be making your iPhone app connect in via a remote Unix shell to the OS X machine (via ssh) and then issuing Unix or AppleScript commands to perform your system actions.
You could also set up a socket connection. I have done a app for Android, that does exactly the same for Windows computers. The app is in use in a computer store :)
For Mac, you have to use sudo command, so you need the user to type in password, on first use.
Then the server application on the Mac can send "sudo shutdown -h now" to the terminal when the server application gets a predefined byte stream on the socket input.