Whenever having to test my app which basically is some kind of communication via sockets with external devices, the device itself has to be available and connected.
I would like to ask,if there is a way to do the testing offline in some kind of simulation mode?
For instance, redirecting the socket communication to some kind of stored file. And the file itself is a log of a previous session with the real device stored in an appropriate structure. Of course one could only simulate a recorded session, but that would help a lot already.
thanks!
You should have a look at netcat. If you have a record of your "session" in a file, you can use nc to "play it back" on a socket with something like:
nc -l -p port_number < your_file
You can then connect to that port number with telnet and you'll see the session data coming in.
(You can do it the other way around too, i.e. have nc connect to your app and replay the session.)
Don't know iphone, but having a local client, (or server), app. as a simulator is very common on other platforms. It's especially useful if the peer app is under development as well - having a simulator often surfaces protocol bugs at both ends, (as well as in the simulator:).
Given an app spec that includes the protocol, but no peer yet, I usually start work on the simulator first - it gives me time to get experience with the protocol in an non-critical, non-deliverable way while the customer is still bolting on changes to the main app UI :)
Rgds,
Martin
Related
I want to run a server on Windows Phone 8. It is important that the server keeps running even if the user opens another app or the screen lock turns on. Relying on an internet connection is not an option. It should work in a local network.
UseCase: The server is needed for a multiplayer game. The idea is that one player starts a local server. After that, all players (including the player who starts the local server) can connect to this server using a webbrowser. The server delivers html and responds to ajax calls.
It seems that PeriodicTask and ResourceIntensiveTask do not fit my needs. Is that correct? How can I run an app in the background that is always listening for incoming tcp connections?
I don't know a clean way. But if you're happy with a hack: You could use the Geolocator. This blog gives a step by step guidance: How to create application which executes in the background on Windows Phone 8?
As most of the hacks, this brings some problems and questions (probably more than I mention here):
If the user turns off the GPS, your server won't be reachable anymore.
I don't know how strict Microsoft is with what you can publish on their store.
No way to do this on Windows Phone.
Can someone please point me in the right direction to create a Mac/PC server app that runs in the background and connects to an iPad app over the local WiFi network?
No matter how I phrase a search on Google it just brings up various apps like Remote Mouse and whatnot and no tutorials or even a hint of where to start.
I just need to send simple commands from iPad to computer over local wifi. A point in the right direction and I can likely fill in the blanks.
Thank you.
Thomas
EDIT: I am using web languages for the iPad version that I will build as a native app using open source tools.
OK, then. It actually depends on what you really need. I made the assumption you need real-time and perhaps binary data transfer.
Your best bet is to write your server application using standard C or C++ so it compiles on both as simply as possible.
If you want to avoid all the burden of writing a protocol for service discovery or asking users to enter the ip address of your server you will use a mDNS implementation for your server and your iPhone app.
If I were you I would try bonjour: http://www.apple.com/support/bonjour/
on iPhone You could start here: http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Articles/PublishingServices.html
Once you have your sockets you will have to implement a networking protocol between your server application and your iPhone app.
You will have to be careful about byte ordering and little subtle problems with latency, disconnections and other problems inherent to networking and WiFi.
In windows you will want to register your application as a service and in Mac OS X/UNIX you'll probably want to deamonize it.
Good luck!
are there any services running by default on an iphone that would let another ip address communicate with it if the iphone's ip is known?
Yes, technically, you can. There are a couple of issues though:
Mobile IP addresses usually change
When the phone is in sleep mode, its network interface is probably not reachable.
So I don't think you can rely on that for initiating a communication with the phone.
There aren't many options out of the box on a non jail-broken phone. However, you can write your own client application that runs on the phone. It accepts or initiates the remote connection.
And in that case, the protocol is entirely up to you.
If you jailbreak your phone, you can install the OpenSSH package and have SSH and SFTP access to your phone.
I don't know exactly what you want to do with your app, but you can consider create a thread detached from the main one (using gcd) and use it to send/receive informations from a server using JSON objects for example. Sure you can use sockets and write a client or something like that.
I suggested a new thread because you can put it running forever (on a enterprise app, I don't know if Apple will approve a thread running on an App for AppStore).
I had to develop an app with a consistent client/server relationship and it was the way I got it working.
I have to write an iphone application that controls a device. This device exposes a telnet based interface. The application should ideally have user access control and customizability for each user.
I was thinking of writing C++ classes that would communicate with the device using sockets. This functionality can then be exposed through web-services that can be called by the iphone application.
However as i looked into it deeper, the api allows you to register for events using telnet and then you can receive notification when those events occur. That kinda put a spanner in the works for me. I for one dont know a "push" scenario can work with webservices.
First off i have never programmed for the iphone so far. So i am not really sure what can be done. So i was thinking if instead of having a webserver to go through, why not have the application independently running on the iphone, directly communicating with the device using sockets. The question though is, is that possible and second i am thinking it would raise a security aspect. First we could control security as everything was going through our central server. Is there a way to handle security (in the sense who has access to the device) without having a central server.
I am sorry that this seems like an unorganized post, but iam trying to brainstorm here.
Looking forward to hear your opinions.
Look up the NSPort and NSStream classes.
I'm looking to do this same thing. Have a program running on one computer and want to send/receive telnet commands from iOS. Built one for Android using the Commons library- which has a telnet client API, but don't know the best way to do it in Objective-C (without writing a telnet client library).
As a start, however, I found the OFC library on Google Code. Looks like something of a Commons-like feel, and there seems to be a telnet client. You might take a look at that.
I want to use ssh protocol. I want to make an app to transmit signal that would ultimately converted to control IR based home appliances (like controlled by IR remote control. i.e. TV)
This stuff is new to me. I don't have any clear understanding about how it will be possible.
I got suggestion to use SSH:
->Install SSH on your server.
->Configure your Network / Router to forward the SSH port to server and
->Use the SSH client on the iPhone.
Now. Is it the only way?
Someone also suggested to develop UPnP base app!
Is there any sample code available using which I can learn How to transmit the signal from iPhone to do above.
Please give some guidence if anybody has done such thing before or if they know how to do?
So that I can understand the flow and put my efforts afterwards.
If I understand correctly, you want to go iPhone->IR transmitter->(some device that is controlled by IR)
If so, you probably want to use whatever protocol the IR transmitter device is expecting.
If it's not expecting anything, I would look to HTTP, rather than SSH. Implementing SSH on the iPhone sounds like a huge hassle, and the only benefit of it is the tight security. Unless the device you are controlling is a nuclear weapon, I would go with some simple HTTP authentication.
For example, if it was a TV you were controlling, you could just request http:///remote.php?action=turnonthetv from your server. Then you'd use a PHP script to generate the IR signal to turn on the TV. This moves a lot of the logic off of the iPhone, which may or may not work with what you're doing.