xtd 0.2.0
Loading...
Searching...
No Matches

◆ connect() [1/3]

void xtd::net::sockets::tcp_client::connect ( const xtd::net::ip_end_point remote_end_point)

Connects the client to a remote TCP host using the specified remote network endpoint.

Parameters
remote_end_pointThe xtd::net::ip_end_point to which you intend to connect.
Exceptions
xtd::net::sockets::socket_exceptionAn error occurred when accessing the socket.
xtd::object_closed_exceptionThe xtd::net::sockets::socket has been closed.
Remarks
Call this method to establish a synchronous remote host connection to the specified xtd::net::ip_end_point. Before you call xtd::net::sockets::tcp_client::connect you must create an instance of the xtd::net::ip_end_point class using an IP address and a port number. Use this xtd::net::ip_end_point as the remote_end_point parameter. The xtd::net::sockets::tcp_client::connect method will block until it either connects or fails. After connecting with the remote host, use the xtd::net::sockets::tcp_client::get_stream method to obtain the underlying xtd::net::sockets::network_stream. Use this xtd::net::sockets::network_stream to send and receive data.
Note
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.
Examples
tcp_client_ip_v4.cpp, and tcp_client_ip_v6.cpp.