xtd
0.2.0
Loading...
Searching...
No Matches
◆
get_stream()
xtd::net::sockets::network_stream
xtd::net::sockets::tcp_client::get_stream
(
)
const
Returns the
xtd::net::sockets::network_stream
used to send and receive data.
Returns
The underlying
xtd::net::sockets::network_stream
.
Remarks
xtd::net::sockets::tcp_client::get_stream
returns a
xtd::net::sockets::network_stream
that you can use to send and receive data. The
xtd::net::sockets::network_stream
class inherits from the std::iostream class, which provides a rich collection of methods and properties used to facilitate network communications.You must call the
xtd::net::sockets::tcp_client::connect
method first, or the
xtd::net::sockets::tcp_client::get_stream
method will throw an
xtd::invalid_operation_exception
. After you have obtained the
xtd::net::sockets::network_stream
, call the std::iostream::write method to send data to the remote host. Call the std::iostream::read method to receive data arriving from the remote host. Both of these methods block until the specified operation is performed. You can avoid blocking on a read operation by checking the
xtd::net::sockets::network_stream::data_available
property. A true value means that data has arrived from the remote host and is available for reading. In this case, std::iostream::read is guaranteed to complete immediately. If the remote host has shutdown its connection, std::iostream::read will immediately return with zero bytes.
Note
You must close the
xtd::net::sockets::network_stream
when you are through sending and receiving data. Closing
xtd::net::sockets::tcp_client
does not release the
xtd::net::sockets::network_stream
.
If you receive a
xtd::net::sockets::socket_exception
, use the
xtd::net::sockets::socket_exception::error_code
property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.
xtd
net
sockets
tcp_client
Generated on Sat Sep 14 2024 21:25:31 for xtd by
Gammasoft
. All rights reserved.