I'm using boost::asio for network communication and I'm wondering why in the examples sometimes the socket.connect(endpoint)
and some other times the boost::asio::connect(socket, endpoint)
is used. According to the code boost::asio::connect
is calling the socket.connect
in a loop for endpoint iterators. So my question is:
Which is better behaviour? Using boost::asio::connect or socket.connect? Personaly I prefer the socket.connect, because I have just one endpoint. Or may I'm wrong and misunderstood the asio libs.
Also my second question is, why the endpoint is an iterator? How can it be possible, more then one connections when 1 ip and 1 port is given?
Also there is a boost::asio::write and socket.write...
The examples are:
- boost::asio::connect(socket, endpoint) blocking_tcp_echo_client.cpp.
- socket.connect(endpoint) (a bit older but still working) Daytime.1