How to create iphone app to react as web server? - objective-c

I'm working on an app, in which server (windows based) will connect to the ipad application. Then data will be transfer from the server to the ipad app. I saw different apps like PDF Expert, Wifi HD, allows server apps to connect to the iphone app through IP address. I decided to use this approach. But I don't know how to implement this. How to make the iphone/ipad app to work as a web server like the above apps do and then transfer data to them from the server side.
BTW I'll run this app on LAN. The app is not for apple's app store. So we can use private API's in it freely (If there is any for this purpose)
Anyone can help me in this regard?
Thanks

First of all, your use of terms client and server seem incorrect (if I understood you correctly). The iPad application is not a server. It is a client. If you have a Windows application as the server, then all you would need to do is have the Windows application open a socket to listen for client connections. The iPad app would connect to the server on the port that the Windows server is listening. That's just the basics of how the client/server architecture works. There's more work that needs to be done for handling disconnects, multiple clients (if you are going to allow that), and other issues.

Try CocoaHTTPServer.

I agree with zooropa, I think you want iPad to be the client, you could setup a HTTP server in windows (with a WAMP, or NIS, or whatever server you like), then in the iPad app, I would create a class to download files with NSURLConnection, check http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html for more information on how to implement a client and handle the requests.
Then when you want to download something, you use something like:
[HTTPClient downloadFile:#"http://lanserver/files/myFile.pdf" To:#"~/MyDocuments/"];
and the class would handle the request and store the file.

Related

Using Electron based app as a web server

I'm developing a cross-platform application (Windows/Linux/macOS), which:
Should be able to run locally as a desktop application
Should be able to run on a remote machine, preferably with the same UI as on local.
So far Electron looks good enough for the first bullet.
The question is about the second one. I'd like to reuse both the logic and the UI from the local scenario for the remote scenario. In other words, I'd like to use Electron based application as a web server and connect to it via browser.
Is there any way to do that?
You can create a remote web server without Electron, just with Node.js, and deliver a web page like a PHP server for example.
But if you want to deliver a complete remote UI and manage the window remotely, that's VERY complicated to do... That needs to configure a lot of things and manage connections between client and server, using asynchronous keyboard & mouse and encryption to secure the communications.
You want a hybrid app I think, like a few of them that out out there (i.e. Slack). Generally there's a web app plus an Electron client version with some shared UI code but it's not Electron all around. The main point of electron is to be a local web server acting as a desktop app. You could certainly keep it all node though.

Recommended WebRTC Server Configuration for Native app (iOS/Android)?

I tried to build a server for integrating the webrtc native APIs in an native app, but I am not sure about how the server should be configured, like the ICE/STUN/TURN, signaling, media server etc..
So far as I know is the open source project: https://github.com/priologic/easyrtc
Can anybody give some recommendations?
Thanks
In a WebRTC infrastructure, there are several things involved. The client part is written in JavaScript and runs on the browser.
But as you said it is a server side part. First there is a ICE/STUN/TURN server that it's used for a client to discover its public IP address if it is located behind a NAT. Depending on your requirements could not be necessary to build/deploy your own server, but use an already public (and free) existing one - here's a list. You can also deploy an open source one like Stuntman.
Then it comes the signaling part, used by two clients to negotiate and start a webrtc session. There is no standard here and you have a few options.
You can use an XMPP server with a Jingle extension. You can deploy an existing XMPP server, like OpenFire or Tigase
You can also use SIP, a protocol much more encountered for VoIP. You can use JAIN-SIP or SIP Servlets.
Or you can develop your own signaling protocol using something like websockets.
The server side options that I was giving you were Java based ones, but you can find similar for other infrastructures too.
STUN/TURN is required. Use public ones (not absolutely stable) or get a Ubuntu machine ans install from the source: https://code.google.com/p/rfc5766-turn-server/
Signaling is trivial. You just forward messages between peers. Just build a simple chat server.
Media server is whole different story and require sophisticated client-server configuration.

establish communication between metro and desktop

I'm trying to make my store app communication with desktop app through websockets.
I know we can make metro app as a client and do WinRT way of communicating over.
For the desktop server part, i'm planning to write a dll that will contain server code and receive metro texts being sent over.
Can someone please tell if this is possible and how to write server code in a dll and if so should we be using winhttp for wbesockets in server side ?
Windows Store (WInRT) apps are executing in a sandbox which isolates them from network communication with other applications on the local machine (localhost). That being said, this protection can be disabled using CheckNetIsolation.exe. Visual Studio automatically does the same for debugging purposes, allowing you to call e.g. a web service on your local machine during development.
As for the desktop side; to communicate with web sockets client, you can make advantage of WinHTTP. There's a working example on MSDN.
Keep in mind, though, that any application communicating with localhost will not be certified for Windows Store and will require several additional steps to install it:
The Windows Store application package will need to be sideloaded since it won't be published in Windows Store.
Any desktop component it communicates with will need to be installed separately the same way as any other desktop application.
Using CheckNetIsolation.exe loopback exemption will need to be added for the Windows Store app.
If you can avoid it, I definitely suggest you don't try communicating directly with a desktop application from you Windows Store app.

Is this possible for a Windows based machine to send and receive data to tailor made app on the iPhone?

I am making an app for the iPhone in Xcode which needs to be able to send and receive excel data from a windows based machine. Making the app is no trouble but what would I need from a PC to access the app data?
Firstly, I wouldn't be using Excel as a data storage program. What you really should be using is a database hosted on a web server with a PHP interface etc. If you choose to go the database route, then you can easily use a Windows machine.
Though if you choose to stick with Excel, it would be theoretically be possible given that people have made apps to have full control of a computer remotely via an app. I just think that this approach is going to be very hard to set up, and will be a lot more clunky than any sort of web server set up. Don't forget that you can get free web server services if the data level is low.
As you mentioned, this PC won't have access to the internet. Assuming you aren't willing to fix that, I guess you'd be left with a Bluetooth or local wifi option. Having to plug it in would really defeat the purpose of an app, and I don't think that iPhones can even do that without mad hacks.
An alternative idea is to build an app that links in with some free web server service, then build VBA code to download it to your Excel sheet. When you plug your iPhone into your PC, use the hotspot to get internet access.

ios upload/download file from desktop

I need my ios device to act like a server i.e. once I connect my iphone with computer I'll be able to upload documents to iphone and as well as download documents from iphone. I know this is possible but I forgot library that allow us to do that. Does anybody knows such library? Also any sample code will be really helpful
Thanks
Refer http://www.cocoadev.com/index.pl?AsyncSocket.
Using socket connection you can make your iphone as a server by running your app which makes a socket connection.