12 Mart 2018 Pazartesi

asio connect metodu

Giriş
Açıklaması şöyle. Birinci parametre socket, ikinci parametre iterator nesnesidir.
This function attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socket's connect member function, once for each endpoint in the sequence, until a connection is successfully established.

Örnek
Şöyle yaparız
std::string host = "192.168.1.3";
std::string port = "8888";
boost::asio::connect(socket, resolver.resolve({host, port}));
Örnek
Şöyle yaparız.
tcp::resolver::iterator it = ...;
tcp::socket socket = ...;
boost::asio::connect (socket, it);
Örnek
Şöyle yaparız.
tcp::resolver resolver(ios);
tcp::resolver::query query(tcp::v4(), host, port);
tcp::resolver::iterator iterator = resolver.resolve(query);

tcp::socket socket (ios);
boost::asio::connect(socket, iterator);


Hiç yorum yok:

Yorum Gönder