0

I'm writing a C# code and running it on a Mac machine using Mono 5.12 framework.

I'm doing upload in the code, the problem I need to check the internet connectivity before doing the upload, there is a DLL on windows that gives you the internet connection status but I don't think I can use it on Mac

[System.Runtime.InteropServices.DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);

obviously since its a dll i can't use it in Mac, is there any relevant dylib that i can use in Mac OS which gives the same results, or any wrapper for the "wininet.dll"

ibr
  • 319
  • 1
  • 5
  • 19
  • Maybe [What is the best way to check for Internet connectivity using .NET?](https://stackoverflow.com/q/2031824/205233) can offer you an alternative. However [this answer](https://stackoverflow.com/a/2172212/205233) makes a valid point in questioning the whole point of checking connectivity. – Filburt Aug 07 '19 at 11:06
  • Thanks, yeah I saw that one before, the problem I can't just get any solution such as `WebClient` because Mono has a bug, if I'm using `WebClient or HttpClient` and the internet was disconnected while I'm getting a response the app just freezes, that's why I was looking for something to check the connectivity without making any web request – ibr Aug 07 '19 at 11:37
  • So Mono won't even respect a set request timeout? That's dire. – Filburt Aug 07 '19 at 11:45
  • yep, the issue is here, https://forums.xamarin.com/discussion/104118/timeout-exception-httpwebrequest-getresponse-in-mono-5-x – ibr Aug 07 '19 at 12:01
  • @ibr https://xamarin.github.io/bugzilla-archives/60/60128/bug.html – SushiHangover Aug 07 '19 at 20:00

0 Answers0