Skip to content

Instantly share code, notes, and snippets.

@kennykerr
Last active August 29, 2015 14:15
Show Gist options
  • Save kennykerr/cd3bb738b8b4e55aa22d to your computer and use it in GitHub Desktop.
Save kennykerr/cd3bb738b8b4e55aa22d to your computer and use it in GitHub Desktop.
#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