use libcurl to check connection

This commit is contained in:
skilion 2016-12-25 22:28:00 +01:00
parent 91c5ac6f31
commit ff58a86b7f

View file

@ -1,6 +1,7 @@
import std.conv;
import std.digest.crc;
import std.file;
import std.net.curl;
import std.path;
import std.regex;
import std.socket;
@ -81,13 +82,9 @@ Regex!char wild2regex(const(char)[] pattern)
// return true if the network connection is available
bool testNetwork()
{
try {
auto addr = new InternetAddress("login.live.com", 443);
auto socket = new TcpSocket(addr);
return socket.isAlive();
} catch (SocketException) {
return false;
}
HTTP http = HTTP("https://login.live.com");
http.method = HTTP.Method.head;
return http.perform(ThrowOnError.no) == 0;
}
// call globMatch for each string in pattern separated by '|'