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

◆ Connect() [3/4]

void System.Net.Sockets.Socket.Connect ( IPAddress[] addresses,
int port )
inline

Definition at line 1294 of file Socket.cs.

1295 {
1297 if (addresses == null)
1298 {
1299 throw new ArgumentNullException("addresses");
1300 }
1301 if (addresses.Length == 0)
1302 {
1304 }
1306 {
1307 throw new ArgumentOutOfRangeException("port");
1308 }
1309 if (_addressFamily != AddressFamily.InterNetwork && _addressFamily != AddressFamily.InterNetworkV6)
1310 {
1311 throw new NotSupportedException(System.SR.net_invalidversion);
1312 }
1313 if (_isConnected)
1314 {
1315 throw new SocketException(10056);
1316 }
1318 foreach (IPAddress iPAddress in addresses)
1319 {
1320 if (CanTryAddressFamily(iPAddress.AddressFamily))
1321 {
1322 try
1323 {
1324 Connect(new IPEndPoint(iPAddress, port));
1325 exceptionDispatchInfo = null;
1326 }
1327 catch (Exception ex) when (!ExceptionCheck.IsFatal(ex))
1328 {
1330 continue;
1331 }
1332 break;
1333 }
1334 }
1335 exceptionDispatchInfo?.Throw();
1336 if (!Connected)
1337 {
1338 throw new ArgumentException(System.SR.net_invalidAddressList, "addresses");
1339 }
1340 }
AddressFamily _addressFamily
Definition Socket.cs:555
bool CanTryAddressFamily(AddressFamily family)
Definition Socket.cs:1159
static bool ValidatePortNumber(int port)
static ExceptionDispatchInfo Capture(Exception source)
static string net_invalidversion
Definition SR.cs:16
static string net_invalidAddressList
Definition SR.cs:42
static string net_sockets_invalid_ipaddress_length
Definition SR.cs:70
Definition SR.cs:7

References System.Net.Sockets.Socket._addressFamily, System.Net.Sockets.Socket._isConnected, System.Net.Sockets.Socket.CanTryAddressFamily(), System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(), System.Net.Sockets.Connect, System.Net.Sockets.Socket.Connected, System.Net.ExceptionCheck.IsFatal(), System.SR.net_invalidAddressList, System.SR.net_invalidversion, System.SR.net_sockets_invalid_ipaddress_length, System.Net.Sockets.Socket.ThrowIfDisposed(), and System.Net.TcpValidationHelpers.ValidatePortNumber().