Created
          November 19, 2014 03:40 
        
      - 
      
- 
        Save jmorrill/bcd199ba67b59f83a969 to your computer and use it in GitHub Desktop. 
    modern2.cpp
  
        
  
    
      This file contains hidden or 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 <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