check internet connectivity in tizen - sockets

I am trying to find out what is the best way check internet connectivity in tizen. Although there is a connection manager I can think of a scenerio where it would not work. Suppose the device is connected to wifi but wifi is not connected to internet. What is the best best way to resolve this issue? I am thinking of using getaddrinfo? But would not that resolve to IP using cached value. Then should I connect to a known website (e.g. google although some country might block it)?

You can hit an address and check for response for certain time of interval. If there is no response for say 2 min or so then you can show message to user that there is some problem with Internet connection.

Related

How to know if a device is connected to a working internet connection in PWA

When creating a progressive web app how can i know that a mobile device is connected to a working internet connection cause it can be connected but not working.
The saying, "You never know until you try" is pertinent here. At the moment you want to check whether there is connectivity, simply fetch a remotely hosted resource with a cache-busting technique. It's generally best practice for that resource to be tiny in file size if you need to check regularly and often (such as 1×1 pixel gif). If you receive a network response in the 200 range, you have connectivity. Otherwise, for the moment at least, you probably don't.

How can i know when i have connection with my server using Reachability?

i need to Implement in my app Error report. i have already have this error report but the problem is that i use the grabURLInBackground to send the error and it's not a good Idea because i need to save those error's in array and ONLY when i have connection with the server i need to send all of those error's together. so my Question is how do i "listen" to a server connection?
how can i know when to send my error's ( Connection is Available ) ? do i need to do it in background? with what?
i hope you guy's Understood me :)
You will get a lot of example code code with Reachability. In fact you can google it.
I didn't found a solution which completely works for me as desired.
Here is a similar question, maybe.
And here is my test cases:
Connect your device to a WI-FI router, and unplug the WLAN from router, so has connection to WI-FI , but no connection to internet.
Case2:
Insert a SIM card, turn on the Allow data at setting via 3G, but the card has no 3G dataplan.
All of Reachability will say there is internet connection and all api calls are fake...

Troubleshooting to connect and disconnect to network

Suppose I have a application which fetch data from network and then showing those data in application. But sometimes internet becomes disconnected so I am showing message that 'Internet not available'. But I want to keep user busy with the application. So I want to do following things but there are some problem in implementation.
1) When network disconnected I want to show message 'network disconnect' and I want to store all data in db.
Problem: How will I know network is not available without happening any event?
2) And when network is connected I want to fetch data and store in buffer.
Problem : Same, how will I know network is available rightnow?
This is quite common question and is best solved using Reachability class.
You can find a nice manual here: Testing Network Reachability
And a quick answer is the accepted answer here:
iPhone reachability checking
But be aware that it's best to check for host availabiility. I tested this code when device was connected to AdHoc WiFi (with no internet connectivity) and the result was: internet available via WiFi. So if you want to be sure - use host status.
EDIT: and this is probably the best example on SO (answer from iWasRobbed):
How to check for an active Internet connection on iOS or OSX?

How can I simplify addressing an iOS device using Bonjour?

I would like to make an application for iOS devices that would communicate with a special type of remote device using HTTP POST requests. The problem is that this device would actually act in the role of a client, while iOS device has to be the server accepting the requests. The next problem, host name and port has to be configured statically at the device sending the requests.
While I'm aware it's possible to give it a try using Dynamic DNS services and UPnP/IGD or NAT-PMP to overcome the problem with iOS device being behind the NAT router, I was wondering whether using Bonjour could simplify the problem in some way. I'm quite a newbie in networking so I'm looking for the direction and want to avoid research of Bonjour if it's not going to bring me anything.
Any other idea of how to solve the problem is appreciated as well.
I had a think about this. IMHO you can't guarantee you'll always be able to expose an iOS based service over a WAN (although it's possible) so this isn't practical.
The best solution I suggest is using uPNP to open the device behind a router to the outside world, then have it send an iOS push notification to the iPhone with the details (hostname, ip, port, etc).
The iPhone would then would then have to set up some kind of persistent connection with the firewalled device to receive data.
Bonjour is a good system to discover and connect to services/clients, but only on your local network. I don't think it is a good idea to try it over the internet.

Question about using Bonjour or other methods to secure a connection with a non computer device

So I have a project I am working on, and I would basically like to send a basic yes/no command from the iPhone to a wifi enabled device that is also connectedto the network on the same router. This other device is not a computer, so I am wondering if I can still use Bonjour? In order to use Bonjour, do both of the communicating devices need to have some sort of a script installed and running that is allowing them to communicate? What would be the best way to connect to this device that is connected to the router, and then to send information/commands to it? I could really use some help finding a direction, because once I identify which tools I need to use, I can research them out and get it done (maybe). If anyone could offer any insight/suggestions whatsoever, it would be greatly appreciated!! Thanks in advance
Bonjour is a local service discovery protocol based on multicast DNS. Even if your device supports it you still need some piece of software on the device to listen to your commands.