Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
basic_stream_socket::async_connect Home Libraries People FAQ More basic_stream_socket::async_connect Inherited from basic_socket. Start an asynchronous connect. template< typename ConnectHandler> void async_connect( const endpoint_type & peer_endpoint, ConnectHandler handler); This function is used to asynchronously connect a socket to the specified remote endpoint. The function call always returns immediately. The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state. Parameters peer_endpoint The remote endpoint to which the socket will be connected. Copies will be made of the endpoint object as required. handler The handler to be called when the connection operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( const boost::system::error_code& error // Result of operation ); Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post(). Example void connect_handler(const boost::system::error_code& error) { if (!error) { // Connect succeeded. } } ... boost::asio::ip::tcp::socket socket(io_service); boost::asio::ip::tcp::endpoint endpoint( boost::asio::ip::address::from_string("1.2.3.4"), 12345); socket.async_connect(endpoint, connect_handler); Copyright © 2003-2011 Christopher M. Kohlhoff Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)