Last active
August 29, 2015 14:15
-
-
Save kennykerr/cd3bb738b8b4e55aa22d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Precompiled.h" | |
#include <modern\async.h> | |
using namespace Modern; | |
using namespace Windows::Networking; | |
using namespace Windows::Networking::Sockets; | |
int main() | |
{ | |
try | |
{ | |
Initialize(); | |
StreamSocket socket; | |
HostName hostname(L"moderncpp.com"); | |
Task(socket.ConnectAsync(hostname, L"80")) | |
.then([] | |
{ | |
printf("Connect succeeded!\n"); | |
}) | |
.wait(); | |
} | |
catch (Exception const & e) | |
{ | |
printf("Connect failed!\n"); | |
MODERN_ASSERT(e.Result == HRESULT_FROM_WIN32(WSAHOST_NOT_FOUND)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment