2011-08-12 3 views

答えて

8

私が覚えている限り、read_someを受け取るは実際に同じことをしています。私はread_someを呼び出すか、その逆を受け取ると思います。もう一つは、むしろビューの接続(送信/受信)ポイントから来ている間、1つの命名は、ファイル(読み取り/書き込み)としてソケットを治療するという考えから来ています。 write_someの場合は、と同じです。

+1

参考文献/リンクはありますか?私はboostドキュメントでは何も見つけられません。boostの例では 'send' /' receive'を使用しません。 – overcoder

0

同じです。 。両方this-を呼び出す> get_serviceは()を送る()basic_stream_socket.hppから

/// Send some data on the socket. 
/** 
* This function is used to send data on the stream socket. The function 
* call will block until one or more bytes of the data has been sent 
* successfully, or an until error occurs. 
* 
* @param buffers One or more data buffers to be sent on the socket. 
* 
* @returns The number of bytes sent. 
* 
* @throws boost::system::system_error Thrown on failure. 
* 
* @note The send operation may not transmit all of the data to the peer. 
* Consider using the @ref write function if you need to ensure that all data 
* is written before the blocking operation completes. 
* 
* @par Example 
* To send a single data buffer use the @ref buffer function as follows: 
* @code 
* socket.send(boost::asio::buffer(data, size)); 
* @endcode 
* See the @ref buffer documentation for information on sending multiple 
* buffers in one go, and how to use it with arrays, boost::array or 
* std::vector. 
*/ 
template <typename ConstBufferSequence> 
std::size_t send(const ConstBufferSequence& buffers) 
{ 
    boost::system::error_code ec; 
    std::size_t s = this->get_service().send(
    this->get_implementation(), buffers, 0, ec); 
    boost::asio::detail::throw_error(ec, "send"); 
    return s; 
} 

//////////////////////////////////////////// 
template <typename ConstBufferSequence> 
std::size_t write_some(const ConstBufferSequence& buffers) 
{ 
    boost::system::error_code ec; 
    std::size_t s = this->get_service().send(
    this->get_implementation(), buffers, 0, ec); 
    boost::asio::detail::throw_error(ec, "write_some"); 
    return s; 
} 

4

BOOST ASIO documentationで、セクションTCPクライアントは言う:

データの読み出しや書き込みが可能

receive()、async_receive()、send()またはasync_send()メンバー関数を使用して、接続されたTCPソケットに接続します。 しかし、アプリケーションは、典型的には、代わりに次の操作を使用する 、これらは short writes or readsにつながる可能性として:() リード()、async_read()は、(書き込み)及びasync_write。

関連する問題