Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ConnectAsync() [6/11]

ValueTask System.Net.Sockets.Socket.ConnectAsync ( IPAddress[] addresses,
int port,
CancellationToken cancellationToken )
inline

Definition at line 3958 of file Socket.cs.

3959 {
3961 if (addresses == null)
3962 {
3963 throw new ArgumentNullException("addresses");
3964 }
3965 if (addresses.Length == 0)
3966 {
3967 throw new ArgumentException(System.SR.net_invalidAddressList, "addresses");
3968 }
3970 {
3971 throw new ArgumentOutOfRangeException("port");
3972 }
3973 if (_isListening)
3974 {
3976 }
3977 if (_isConnected)
3978 {
3979 throw new SocketException(10056);
3980 }
3983 {
3984 Exception source = null;
3985 IPEndPoint endPoint = null;
3986 foreach (IPAddress address in addresses)
3987 {
3988 try
3989 {
3990 if (endPoint == null)
3991 {
3992 endPoint = new IPEndPoint(address, port);
3993 }
3994 else
3995 {
3996 endPoint.Address = address;
3997 }
3999 return;
4000 }
4001 catch (Exception ex) when (!(ex is OperationCanceledException))
4002 {
4003 source = ex;
4004 }
4005 }
4007 }
4008 }
bool ConnectAsync(SocketAsyncEventArgs e)
Definition Socket.cs:2822
static bool ValidatePortNumber(int port)
static string net_invalidAddressList
Definition SR.cs:42
static string net_sockets_mustnotlisten
Definition SR.cs:64
Definition SR.cs:7

References System.Net.Sockets.Socket._isConnected, System.Net.Sockets.Socket._isListening, System.cancellationToken, System.Net.Sockets.Socket.ConnectAsync(), System.SR.net_invalidAddressList, System.SR.net_sockets_mustnotlisten, System.source, System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(), System.Net.Sockets.Socket.ThrowIfDisposed(), and System.Net.TcpValidationHelpers.ValidatePortNumber().