Advertisement
wheeler

wxWidgets 3.0.1.0 and boost::asio

Aug 24th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include "wx/wx.h"
  2. #include <boost/asio.hpp>
  3. #include <iostream>
  4.  
  5. class app_frame :
  6.     public wxFrame
  7. {
  8.     private:
  9.         wxPanel *panel;
  10.     public:
  11.         app_frame() : wxFrame(0, wxID_ANY, wxT("wxWidgets 3 and boost::asio"), wxPoint(0,0), wxSize(300,600))
  12.         {
  13.         }
  14. };
  15.  
  16. class app :
  17.     public wxApp
  18. {
  19.     public:
  20.         virtual bool OnInit()
  21.         {
  22.             boost::asio::io_service io;
  23.             boost::asio::ip::tcp::socket sock(io);
  24.             boost::asio::ip::tcp::resolver res(io);
  25.             auto end_it = res.resolve({ "localhost", "5000" });
  26.             std::cout << "Connecting...\n";
  27.             boost::asio::async_connect(sock, end_it, [&](boost::system::error_code ec, boost::asio::ip::tcp::resolver::iterator iter) {
  28.                 if (!ec)
  29.                     std::cout << "Connected!!!!\n";
  30.                 else
  31.                     std::cout << "Not connected!!!!\n";
  32.             });
  33.             frame = new app_frame;
  34.             frame->Show();
  35.             return true;
  36.         }
  37.     private:
  38.         app_frame *frame;
  39. };
  40.  
  41. IMPLEMENT_APP(app);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement