Skip to content

Instantly share code, notes, and snippets.

@jmorrill
Created November 19, 2014 03:40
Show Gist options
  • Save jmorrill/bcd199ba67b59f83a969 to your computer and use it in GitHub Desktop.
Save jmorrill/bcd199ba67b59f83a969 to your computer and use it in GitHub Desktop.
modern2.cpp
#include "Precompiled.h"
#include <stdio.h>
#include <ppltasks.h>
#include <iostream>
#include <string>
using namespace Modern::Windows::Foundation;
using namespace Modern::Windows::Networking::Connectivity;
using namespace Modern::Windows::Networking;
using namespace Modern::Windows::Networking::Sockets;
int main()
{
Modern::Initialize();
Uri uri(L"http://moderncpp.com/about/");
auto socket = StreamSocket();
auto profiles = NetworkInformation::GetConnectionProfiles();
IConnectionProfile profile;
profiles.GetAbi()->GetAt(0, profile.GetAddressOfAbi());
INetworkAdapter adaptor;
adaptor = profile.NetworkAdapter();
auto hostname = HostName(L"moderncpp.com");
try
{
socket.ConnectAsync(hostname, L"80", SocketProtectionLevel::PlainSocket, adaptor).
Completed([](auto const &, AsyncStatus const &)
{
printf("connected");
});
}
catch (Modern::Exception& ex)
{
std::cout << ex.Result << std::endl;
}
std::string line;
std::getline(std::cin, line);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment