Connection of Electric IMP agent URL for Socket in iOS

Hi

I need to create socket for electric imp agent url for iOS App. Please suggest Is it possible? if yes, Would it work with port 8080(common port) or if any other port available, kindly provide it.

Thanks,

If you’re trying to connect to the agent from your app, that’s just a straightforward NSURLConnection (or NSURLSession, if you want to be future-proof). You just connect to the agent’s URL.

`NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:<YOUR_AGENT_URL>] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];`

If you want the agent to initiate the connection to the app, however, that’s very difficult because iDevices are not exposed as servers.

IIRC, the connection occurs through the standard HTTP/HTTPS port 80.

Hi Smittytone , thanks for sharing us the above information.

actually i want to refresh agenturl data in every second by getting the data into background. so thats why i need to create socket. Kindly help.

Thanks,

This is something I have been thinking about too - I want to implement real time control of a variable in the device via the agent from an iOS device. The problem with using NSURLConnection (et al) is not the agent, which is very fast, but the iOS device is slow to create and complete the request multiple times. I had thought of using NSStream, but I don’t see a way to “listen” for this at the agent. One other option is call the agent first and have it use long polling outbound (httprequest.sendasync) and put some server in the middle between the agent and iOS device. A bit Rube Goldberg but I’m going to give it a try.