UDT Reference: CUDT Methods

connect

The connect method connects to a server UDT entity and constructs a UDT connection.

void connect(
   const char* ip,

   const int& port,

   const int& timeo = 0
);

Parameters

ip
[in] The server IP address or domain name.
 
port
[in] The port number that the is listening.
 
timeo
[in] The time (in microseconds) to wait before a successful connection. 

Return Values

NONE.

Exceptions

Exception will be threw out if no server is ready to be connected at the given ip and port address before timer expires (if timeo is greater than 0).

Description

The connect method tries to connect to the UDT server at ip:port, even there is no such a server. A UDT server is NOT necessarily to be started earlier than the client side. The connect method keeps querying the UDP port at ip until it receives a handshake packet from the server, which has called listen at that time.

The client side sends handshake packets to the server with its own initial maximum flow window size and MTU. Once it receives feedback from the server, these values are updated with the values in the returned handshake packet.

The sending and receiving threads are started after connect, and the UDT entity is ready for data transfer.

If the timeo is not greater than 0,  the method will be indefinitely blocked until the connection is successfully brought up. Otherwise, it will exit with an exception if connection is not built before timer expires.

See Also

open, listen