[Boost] ASIO學習筆記:network basic – client
對於網路程式設計而言,不外乎是server或者是client程式這二種。 而怎麼讓二台遠端的電腦透過網路溝通的程式設計,稱作socket programming。 現在就讓我們先從最基本的client端連接到遠端server的程式開始: #include <boost/asio.hpp> #include <boost/shared_ptr.hpp> #include <iostream> #include <string> using namespace std; int main( int argc, char * argv[] ) { boost::shared_ptr< boost::asio::io_service > io_service(new boost::asio::io_service); boost::asio::ip::tcp::socket sock( *io_service ); boost::asio::ip::tcp::resolver resolver(*io_service); boost::asio::ip::tcp::resolver::query query( “www.yahoo.com.tw”, “80”); boost::asio::ip::tcp::resolver::iterator … Continued