18 private class HandshakeDoneProcedure
20 private TlsStream m_SecureStream;
22 private object m_Request;
26 internal static RemoteCertValidationCallback CreateAdapter(
ServicePoint serviePoint, TlsStream secureStream,
object request)
28 HandshakeDoneProcedure @
object =
new HandshakeDoneProcedure(serviePoint, secureStream, request);
29 return @
object.CertValidationCallback;
32 private HandshakeDoneProcedure(
ServicePoint serviePoint, TlsStream secureStream,
object request)
34 m_ServicePoint = serviePoint;
35 m_SecureStream = secureStream;
41 m_ServicePoint.UpdateServerCertificate(certificate);
42 m_ServicePoint.UpdateClientCertificate(m_SecureStream.ClientCertificate);
45 if (httpWebRequest !=
null && httpWebRequest.ServerCertValidationCallback !=
null)
47 return httpWebRequest.ServerCertValidationCallback.Invoke(m_Request, certificate, chain, sslPolicyErrors);
52 bool flag2 =
ServicePointManager.CertPolicyValidationCallback.Invoke(hostName, m_ServicePoint, certificate, (
WebRequest)m_Request, chain, sslPolicyErrors);
61 return ServicePointManager.ServerCertValidationCallback.Invoke(m_Request, certificate, chain, sslPolicyErrors);
71 private class ConnectSocketState
79 internal object owner;
83 internal int currentIndex;
87 internal int unsuccessfulAttempts;
89 internal bool connectFailure;
91 internal PooledStream pooledStream;
93 internal ConnectSocketState(
ServicePoint servicePoint, PooledStream pooledStream,
object owner,
Socket s4,
Socket s6)
95 this.servicePoint = servicePoint;
96 this.pooledStream = pooledStream;
103 internal const int LoopbackConnectionLimit =
int.MaxValue;
105 private int m_ConnectionLeaseTimeout;
107 private TimerThread.Queue m_ConnectionLeaseTimerQueue;
109 private bool m_ProxyServicePoint;
111 private bool m_UserChangedLimit;
113 private bool m_UseNagleAlgorithm;
115 private TriState m_HostLoopbackGuess;
117 private int m_ReceiveBufferSize;
119 private bool m_Expect100Continue;
121 private bool m_Understands100Continue;
123 private HttpBehaviour m_HttpBehaviour;
125 private string m_LookupString;
127 private int m_ConnectionLimit;
131 private Uri m_Address;
133 private string m_Host;
137 private TimerThread.Queue m_IdlingQueue;
139 private TimerThread.Timer m_ExpiringTimer;
143 private string m_ConnectionName;
145 private int m_CurrentConnections;
147 private bool m_HostMode;
151 private object m_CachedChannelBinding;
153 private static readonly
AsyncCallback m_ConnectCallbackDelegate = ConnectSocketCallback;
155 private readonly TimerThread.Callback m_IdleConnectionGroupTimeoutDelegate;
157 private object m_ServerCertificateOrBytes;
159 private object m_ClientCertificateOrBytes;
161 private bool m_UseTcpKeepAlive;
163 private int m_TcpKeepAliveTime;
165 private int m_TcpKeepAliveInterval;
167 private string m_HostName =
string.Empty;
169 private bool m_IsTrustedHost =
true;
173 private int m_CurrentAddressInfoIndex;
175 private bool m_ConnectedSinceDns;
177 private bool m_AddressListFailed;
181 private bool m_IPAddressesAreLoopback;
183 internal string LookupString => m_LookupString;
185 internal string Hostname => m_HostName;
187 internal bool IsTrustedHost => m_IsTrustedHost;
195 return m_BindIPEndPointDelegate;
199 ExceptionHelper.InfrastructurePermission.Demand();
200 m_BindIPEndPointDelegate = value;
204 internal object CachedChannelBinding => m_CachedChannelBinding;
213 return m_ConnectionLeaseTimeout;
217 if (!ValidationHelper.ValidateRange(value, -1,
int.MaxValue))
221 if (value != m_ConnectionLeaseTimeout)
223 m_ConnectionLeaseTimeout = value;
224 m_ConnectionLeaseTimerQueue =
null;
229 internal TimerThread.
Queue ConnectionLeaseTimerQueue
233 TimerThread.Queue connectionLeaseTimerQueue = m_ConnectionLeaseTimerQueue;
234 if (connectionLeaseTimerQueue ==
null)
236 connectionLeaseTimerQueue = (m_ConnectionLeaseTimerQueue = TimerThread.GetOrCreateQueue(
ConnectionLeaseTimeout));
238 return m_ConnectionLeaseTimerQueue;
253 if (m_ProxyServicePoint)
255 ExceptionHelper.WebPermissionUnrestricted.Demand();
261 internal Uri InternalAddress => m_Address;
271 return m_Address.
Host;
275 internal int Port => m_Port;
285 return m_IdlingQueue.Duration;
289 if (!ValidationHelper.ValidateRange(value, -1,
int.MaxValue))
293 if (value != m_IdlingQueue.Duration)
297 if (m_ExpiringTimer ==
null || m_ExpiringTimer.Cancel())
299 m_IdlingQueue = TimerThread.GetOrCreateQueue(value);
300 if (m_ExpiringTimer !=
null)
302 double totalMilliseconds = (
DateTime.
Now - m_IdleSince).TotalMilliseconds;
303 int num = (totalMilliseconds >= 2147483647.0) ?
int.MaxValue : ((int)totalMilliseconds);
304 int durationMilliseconds = (value == -1) ? (-1) : ((num < value) ? (value - num) : 0);
305 m_ExpiringTimer = TimerThread.CreateQueue(durationMilliseconds).CreateTimer(
ServicePointManager.IdleServicePointTimeoutDelegate,
this);
320 return m_UseNagleAlgorithm;
324 m_UseNagleAlgorithm = value;
335 return m_ReceiveBufferSize;
339 if (!ValidationHelper.ValidateRange(value, -1,
int.MaxValue))
343 m_ReceiveBufferSize = value;
354 return m_Expect100Continue;
358 m_Expect100Continue = value;
372 if ((
int)m_HttpBehaviour <= 1 && m_HttpBehaviour != 0)
380 internal HttpBehaviour HttpBehaviour
384 return m_HttpBehaviour;
388 m_HttpBehaviour = value;
389 m_Understands100Continue = (m_Understands100Continue && ((int)m_HttpBehaviour > 1 || m_HttpBehaviour == HttpBehaviour.Unknown));
404 if (!m_UserChangedLimit && m_IPAddressInfoList ==
null && m_HostLoopbackGuess == TriState.Unspecified)
408 if (!m_UserChangedLimit && m_IPAddressInfoList ==
null && m_HostLoopbackGuess == TriState.Unspecified)
413 m_HostLoopbackGuess = (IsAddressListLoopback(
new IPAddress[1]
416 }) ? TriState.True : TriState.False);
420 m_HostLoopbackGuess = (NclUtilities.GuessWhetherHostIsLoopback(m_Host) ? TriState.True : TriState.False);
425 if (!m_UserChangedLimit && !((m_IPAddressInfoList ==
null) ? (m_HostLoopbackGuess != TriState.True) : (!m_IPAddressesAreLoopback)))
429 return m_ConnectionLimit;
437 if (!m_UserChangedLimit || m_ConnectionLimit != value)
441 if (!m_UserChangedLimit || m_ConnectionLimit != value)
443 m_ConnectionLimit = value;
444 m_UserChangedLimit =
true;
445 ResolveConnectionLimit();
461 foreach (ConnectionGroup value
in m_ConnectionGroupList.
Values)
463 num += value.CurrentConnections;
476 object serverCertificateOrBytes = m_ServerCertificateOrBytes;
477 if (serverCertificateOrBytes !=
null && serverCertificateOrBytes.GetType() == typeof(
byte[]))
491 object clientCertificateOrBytes = m_ClientCertificateOrBytes;
492 if (clientCertificateOrBytes !=
null && clientCertificateOrBytes.GetType() == typeof(
byte[]))
507 if ((
int)m_HttpBehaviour <= 1)
509 return m_HttpBehaviour == HttpBehaviour.Unknown;
515 internal bool Understands100Continue
519 return m_Understands100Continue;
523 m_Understands100Continue = value;
527 internal bool InternalProxyServicePoint => m_ProxyServicePoint;
529 private bool HasTimedOut
533 int dnsRefreshTimeout = ServicePointManager.DnsRefreshTimeout;
534 if (dnsRefreshTimeout != -1)
536 return m_LastDnsResolve +
new TimeSpan(0, 0, 0, 0, dnsRefreshTimeout) <
DateTime.UtcNow;
542 internal ServicePoint(Uri address, TimerThread.Queue defaultIdlingQueue,
int defaultConnectionLimit,
string lookupString,
bool userChangedLimit,
bool proxyServicePoint)
546 Logging.Enter(Logging.Web,
this,
"ServicePoint", address.DnsSafeHost +
":" + address.Port);
548 m_ProxyServicePoint = proxyServicePoint;
550 m_ConnectionName = address.
Scheme;
551 m_Host = address.DnsSafeHost;
552 m_Port = address.Port;
553 m_IdlingQueue = defaultIdlingQueue;
554 m_ConnectionLimit = defaultConnectionLimit;
555 m_HostLoopbackGuess = TriState.Unspecified;
556 m_LookupString = lookupString;
557 m_UserChangedLimit = userChangedLimit;
558 m_UseNagleAlgorithm = ServicePointManager.UseNagleAlgorithm;
559 m_Expect100Continue = ServicePointManager.Expect100Continue;
560 m_ConnectionGroupList =
new Hashtable(10);
561 m_ConnectionLeaseTimeout = -1;
562 m_ReceiveBufferSize = -1;
563 m_UseTcpKeepAlive = ServicePointManager.s_UseTcpKeepAlive;
564 m_TcpKeepAliveTime = ServicePointManager.s_TcpKeepAliveTime;
565 m_TcpKeepAliveInterval = ServicePointManager.s_TcpKeepAliveInterval;
566 m_Understands100Continue =
true;
567 m_HttpBehaviour = HttpBehaviour.Unknown;
569 m_ExpiringTimer = m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate,
this);
570 m_IdleConnectionGroupTimeoutDelegate = IdleConnectionGroupTimeoutCallback;
573 internal ServicePoint(
string host,
int port, TimerThread.Queue defaultIdlingQueue,
int defaultConnectionLimit,
string lookupString,
bool userChangedLimit,
bool proxyServicePoint)
577 Logging.Enter(Logging.Web,
this,
"ServicePoint", host +
":" + port);
579 m_ProxyServicePoint = proxyServicePoint;
581 m_IdlingQueue = defaultIdlingQueue;
582 m_ConnectionLimit = defaultConnectionLimit;
583 m_HostLoopbackGuess = TriState.Unspecified;
584 m_LookupString = lookupString;
585 m_UserChangedLimit = userChangedLimit;
586 m_ConnectionGroupList =
new Hashtable(10);
587 m_ConnectionLeaseTimeout = -1;
588 m_ReceiveBufferSize = -1;
593 m_ExpiringTimer = m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate,
this);
594 m_IdleConnectionGroupTimeoutDelegate = IdleConnectionGroupTimeoutCallback;
597 internal void SetCachedChannelBinding(Uri uri,
ChannelBinding binding)
599 if (uri.Scheme == Uri.UriSchemeHttps)
601 m_CachedChannelBinding = ((binding !=
null) ? ((
object)binding) : ((
object)
DBNull.Value));
605 private ConnectionGroup FindConnectionGroup(
string connName,
bool dontCreate)
607 string key = ConnectionGroup.MakeQueryStr(connName);
608 ConnectionGroup connectionGroup = m_ConnectionGroupList[key] as ConnectionGroup;
609 if (connectionGroup ==
null && !dontCreate)
611 connectionGroup =
new ConnectionGroup(
this, connName);
612 m_ConnectionGroupList[key] = connectionGroup;
614 return connectionGroup;
617 internal Socket GetConnection(PooledStream PooledStream,
object owner,
bool async, out IPAddress address, ref
Socket abortSocket, ref
Socket abortSocket6)
622 Exception exception =
null;
633 abortSocket = socket;
634 abortSocket6 = socket2;
635 ConnectSocketState state =
null;
638 state =
new ConnectSocketState(
this, PooledStream, owner, socket, socket2);
640 webExceptionStatus = ConnectSocket(socket, socket2, ref socket3, ref address, state, out exception);
641 switch (webExceptionStatus)
646 throw new WebException(NetRes.GetWebStatusString(webExceptionStatus), (webExceptionStatus ==
WebExceptionStatus.ProxyNameResolutionFailure || webExceptionStatus ==
WebExceptionStatus.NameResolutionFailure) ? Host :
null, exception, webExceptionStatus,
null, WebExceptionInternalStatus.ServicePointFatal);
650 throw new IOException(SR.GetString(
"net_io_transportfailure"));
652 CompleteGetConnection(socket, socket2, socket3, address);
657 private void CompleteGetConnection(
Socket socket,
Socket socket6,
Socket finalSocket, IPAddress address)
667 else if (socket !=
null)
680 if (m_UseTcpKeepAlive)
688 (byte)(m_TcpKeepAliveTime & 0xFF),
689 (byte)((m_TcpKeepAliveTime >> 8) & 0xFF),
690 (byte)((m_TcpKeepAliveTime >> 16) & 0xFF),
691 (byte)((m_TcpKeepAliveTime >> 24) & 0xFF),
692 (byte)(m_TcpKeepAliveInterval & 0xFF),
693 (byte)((m_TcpKeepAliveInterval >> 8) & 0xFF),
694 (byte)((m_TcpKeepAliveInterval >> 16) & 0xFF),
695 (byte)((m_TcpKeepAliveInterval >> 24) & 0xFF)
700 internal virtual void SubmitRequest(HttpWebRequest request)
702 SubmitRequest(request,
null);
705 internal void SubmitRequest(HttpWebRequest request,
string connName)
707 bool forcedsubmit =
false;
708 ConnectionGroup connectionGroup;
711 connectionGroup = FindConnectionGroup(connName, dontCreate:
false);
713 Connection connection;
716 connection = connectionGroup.FindConnection(request, connName, out forcedsubmit);
718 while (connection !=
null && !connection.SubmitRequest(request, forcedsubmit));
726 if (ReleaseConnectionGroup(
HttpWebRequest.GenerateConnectionGroup(connectionGroupName, unsafeConnectionGroup:
false, isInternalGroup:
false).ToString()) || ReleaseConnectionGroup(
HttpWebRequest.GenerateConnectionGroup(connectionGroupName, unsafeConnectionGroup:
true, isInternalGroup:
false).ToString()) || ConnectionPoolManager.RemoveConnectionPool(
this, connectionGroupName))
733 internal void CloseConnectionGroupInternal(
string connectionGroupName)
735 string value =
HttpWebRequest.GenerateConnectionGroup(connectionGroupName, unsafeConnectionGroup:
false, isInternalGroup:
true).ToString();
736 string value2 =
HttpWebRequest.GenerateConnectionGroup(connectionGroupName, unsafeConnectionGroup:
true, isInternalGroup:
true).ToString();
740 foreach (
object key
in m_ConnectionGroupList.
Keys)
742 string text = key as string;
755 foreach (
string item
in list)
757 ReleaseConnectionGroup(item);
762 private void ResolveConnectionLimit()
765 foreach (ConnectionGroup value
in m_ConnectionGroupList.
Values)
767 value.ConnectionLimit = connectionLimit;
773 if (certificate !=
null)
779 m_ServerCertificateOrBytes =
null;
785 if (certificate !=
null)
791 m_ClientCertificateOrBytes =
null;
804 m_UseTcpKeepAlive =
true;
805 if (keepAliveTime <= 0)
809 if (keepAliveInterval <= 0)
813 m_TcpKeepAliveTime = keepAliveTime;
814 m_TcpKeepAliveInterval = keepAliveInterval;
818 m_UseTcpKeepAlive =
false;
819 m_TcpKeepAliveTime = 0;
820 m_TcpKeepAliveInterval = 0;
824 internal void IncrementConnection()
828 m_CurrentConnections++;
829 if (m_CurrentConnections == 1)
831 m_ExpiringTimer.Cancel();
832 m_ExpiringTimer =
null;
837 internal void DecrementConnection()
841 m_CurrentConnections--;
842 if (m_CurrentConnections == 0)
845 m_ExpiringTimer = m_IdlingQueue.CreateTimer(ServicePointManager.IdleServicePointTimeoutDelegate,
this);
847 else if (m_CurrentConnections < 0)
849 m_CurrentConnections = 0;
854 internal RemoteCertValidationCallback SetupHandshakeDoneProcedure(TlsStream secureStream,
object request)
856 return HandshakeDoneProcedure.CreateAdapter(
this, secureStream, request);
859 private void IdleConnectionGroupTimeoutCallback(TimerThread.Timer timer,
int timeNoticed,
object context)
861 ConnectionGroup connectionGroup = (ConnectionGroup)context;
864 Logging.PrintInfo(Logging.Web,
this, SR.GetString(
"net_log_closed_idle",
"ConnectionGroup", connectionGroup.GetHashCode()));
866 ReleaseConnectionGroup(connectionGroup.Name);
869 internal TimerThread.Timer CreateConnectionGroupTimer(ConnectionGroup connectionGroup)
871 return m_IdlingQueue.CreateTimer(m_IdleConnectionGroupTimeoutDelegate, connectionGroup);
874 internal bool ReleaseConnectionGroup(
string connName)
876 ConnectionGroup connectionGroup =
null;
879 connectionGroup = FindConnectionGroup(connName, dontCreate:
true);
880 if (connectionGroup ==
null)
884 connectionGroup.CancelIdleTimer();
885 m_ConnectionGroupList.
Remove(connName);
887 connectionGroup.DisableKeepAliveOnConnections();
891 internal void ReleaseAllConnectionGroups()
896 foreach (ConnectionGroup value
in m_ConnectionGroupList.
Values)
898 arrayList.
Add(value);
900 m_ConnectionGroupList.
Clear();
902 foreach (ConnectionGroup item
in arrayList)
904 item.DisableKeepAliveOnConnections();
908 private static void ConnectSocketCallback(IAsyncResult asyncResult)
910 ConnectSocketState connectSocketState = (ConnectSocketState)asyncResult.AsyncState;
912 IPAddress address =
null;
913 Exception exception =
null;
918 webExceptionStatus = connectSocketState.servicePoint.ConnectSocketInternal(connectSocketState.connectFailure, connectSocketState.s4, connectSocketState.s6, ref socket, ref address, connectSocketState, asyncResult, out exception);
924 catch (ObjectDisposedException ex2)
928 switch (webExceptionStatus)
935 connectSocketState.servicePoint.CompleteGetConnection(connectSocketState.s4, connectSocketState.s6, socket, address);
941 catch (ObjectDisposedException ex4)
947 e =
new WebException(NetRes.GetWebStatusString(webExceptionStatus), (webExceptionStatus ==
WebExceptionStatus.ProxyNameResolutionFailure || webExceptionStatus ==
WebExceptionStatus.NameResolutionFailure) ? connectSocketState.servicePoint.Host :
null, exception, webExceptionStatus,
null, WebExceptionInternalStatus.ServicePointFatal);
952 connectSocketState.pooledStream.ConnectionCallback(connectSocketState.owner, e, socket, address);
956 if (socket ==
null || !socket.CleanedUp)
963 private void BindUsingDelegate(
Socket socket, IPEndPoint remoteIPEndPoint)
965 IPEndPoint remoteEndPoint =
new IPEndPoint(remoteIPEndPoint.Address, remoteIPEndPoint.Port);
967 for (i = 0; i <
int.MaxValue; i++)
969 IPEndPoint iPEndPoint = BindIPEndPointDelegate(
this, remoteEndPoint, i);
970 if (iPEndPoint !=
null)
974 socket.InternalBind(iPEndPoint);
983 if (i ==
int.MaxValue)
985 throw new OverflowException(
"Reached maximum number of BindIPEndPointDelegate retries");
989 private void SetUnicastReusePortForSocket(
Socket socket)
991 if ((!ServicePointManager.ReusePortSupported.HasValue || ServicePointManager.ReusePortSupported.Value) && ServicePointManager.ReusePort)
998 Logging.PrintInfo(Logging.Web,
this, SR.GetString(
"net_log_set_socketoption_reuseport",
"Socket", socket.GetHashCode()));
1000 ServicePointManager.ReusePortSupported =
true;
1006 Logging.PrintInfo(Logging.Web,
this, SR.GetString(
"net_log_set_socketoption_reuseport_not_supported",
"Socket", socket.GetHashCode()));
1008 ServicePointManager.ReusePortSupported =
false;
1010 catch (Exception ex2)
1014 Logging.PrintInfo(Logging.Web,
this, SR.GetString(
"net_log_unexpected_exception", ex2.Message));
1020 private WebExceptionStatus ConnectSocketInternal(
bool connectFailure,
Socket s4,
Socket s6, ref
Socket socket, ref IPAddress address, ConnectSocketState state, IAsyncResult asyncResult, out Exception exception)
1023 IPAddress[] array =
null;
1024 for (
int i = 0; i < 2; i++)
1028 if (asyncResult ==
null)
1030 array = GetIPAddressInfoList(out currentIndex, array);
1031 if (array ==
null || array.Length == 0)
1038 array = state.addresses;
1039 currentIndex = state.currentIndex;
1041 i = state.unsuccessfulAttempts;
1043 for (; j < array.Length; j++)
1045 IPAddress iPAddress = array[currentIndex];
1048 IPEndPoint iPEndPoint =
new IPEndPoint(iPAddress, m_Port);
1049 Socket socket2 = (iPEndPoint.Address.AddressFamily !=
AddressFamily.InterNetwork) ? s6 : s4;
1052 if (asyncResult ==
null)
1054 state.addresses = array;
1055 state.currentIndex = currentIndex;
1057 state.unsuccessfulAttempts = i;
1058 state.connectFailure = connectFailure;
1061 if (ServicePointManager.ReusePort)
1063 SetUnicastReusePortForSocket(socket2);
1065 if (BindIPEndPointDelegate !=
null)
1067 BindUsingDelegate(socket2, iPEndPoint);
1070 socket2.UnsafeBeginConnect(iPEndPoint, m_ConnectCallbackDelegate, state);
1073 IAsyncResult asyncResult2 = asyncResult;
1081 if (ServicePointManager.ReusePort)
1083 SetUnicastReusePortForSocket(socket2);
1085 if (BindIPEndPointDelegate !=
null)
1087 BindUsingDelegate(socket2, iPEndPoint);
1090 socket2.InternalConnect(iPEndPoint);
1093 address = iPAddress;
1095 UpdateCurrentIndex(array, currentIndex);
1098 catch (ObjectDisposedException)
1102 catch (Exception ex2)
1104 if (NclUtilities.IsFatal(ex2))
1109 connectFailure =
true;
1112 if (currentIndex >= array.Length)
1119 if (!connectFailure)
1121 if (!InternalProxyServicePoint)
1132 return ConnectSocketInternal(connectFailure:
false, s4, s6, ref socket, ref address, state,
null, out exception);
1136 internal void DebugMembers(
int requestHash)
1138 foreach (ConnectionGroup value
in m_ConnectionGroupList.
Values)
1152 private void Failed(IPAddress[] addresses)
1154 if (addresses == m_IPAddressInfoList)
1158 if (addresses == m_IPAddressInfoList)
1160 m_AddressListFailed =
true;
1166 private void UpdateCurrentIndex(IPAddress[] addresses,
int currentIndex)
1168 if (addresses == m_IPAddressInfoList && (m_CurrentAddressInfoIndex != currentIndex || !m_ConnectedSinceDns))
1172 if (addresses == m_IPAddressInfoList)
1174 if (!ServicePointManager.EnableDnsRoundRobin)
1176 m_CurrentAddressInfoIndex = currentIndex;
1178 m_ConnectedSinceDns =
true;
1184 private IPAddress[] GetIPAddressInfoList(out
int currentIndex, IPAddress[] addresses)
1186 IPHostEntry result =
null;
1192 if (addresses !=
null && !m_ConnectedSinceDns && !m_AddressListFailed && addresses == m_IPAddressInfoList)
1196 if (m_IPAddressInfoList ==
null || m_AddressListFailed || addresses == m_IPAddressInfoList || HasTimedOut)
1198 m_CurrentAddressInfoIndex = 0;
1199 m_ConnectedSinceDns =
false;
1200 m_AddressListFailed =
false;
1201 m_LastDnsResolve =
DateTime.UtcNow;
1209 flag2 = !
Dns.TryInternalResolve(m_Host, out result);
1211 catch (Exception exception)
1213 if (NclUtilities.IsFatal(exception))
1224 m_IPAddressInfoList =
null;
1225 if (!flag2 && result !=
null && result.AddressList !=
null && result.AddressList.Length != 0)
1227 SetAddressList(result);
1230 if (m_IPAddressInfoList !=
null && m_IPAddressInfoList.Length != 0)
1232 currentIndex = m_CurrentAddressInfoIndex;
1233 if (ServicePointManager.EnableDnsRoundRobin)
1235 m_CurrentAddressInfoIndex++;
1236 if (m_CurrentAddressInfoIndex >= m_IPAddressInfoList.Length)
1238 m_CurrentAddressInfoIndex = 0;
1241 return m_IPAddressInfoList;
1247 private void SetAddressList(IPHostEntry ipHostEntry)
1249 bool iPAddressesAreLoopback = m_IPAddressesAreLoopback;
1250 bool flag = m_IPAddressInfoList ==
null;
1251 m_IPAddressesAreLoopback = IsAddressListLoopback(ipHostEntry.AddressList);
1252 m_IPAddressInfoList = ipHostEntry.AddressList;
1253 m_HostName = ipHostEntry.HostName;
1254 m_IsTrustedHost = ipHostEntry.isTrustedHost;
1255 if (flag || iPAddressesAreLoopback != m_IPAddressesAreLoopback)
1257 ResolveConnectionLimit();
1261 private static bool IsAddressListLoopback(IPAddress[] addressList)
1263 IPAddress[] array =
null;
1266 array = NclUtilities.LocalAddresses;
1268 catch (Exception ex)
1270 if (NclUtilities.IsFatal(ex))
1276 Logging.PrintError(Logging.Web, SR.GetString(
"net_log_retrieving_localhost_exception", ex));
1277 Logging.PrintWarning(Logging.Web, SR.GetString(
"net_log_resolved_servicepoint_may_not_be_remote_server"));
1281 for (i = 0; i < addressList.Length; i++)
1283 if (!IPAddress.IsLoopback(addressList[i]))
1290 for (j = 0; j < array.Length && !addressList[i].Equals(array[j]); j++)
1293 if (j >= array.Length)
1299 return i == addressList.Length;
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
DateTime IdleSince
Gets the date and time that the T:System.Net.ServicePoint object was last connected to a host.
static RemoteCertificateValidationCallback ServerCertificateValidationCallback
Gets or sets the callback to validate a server certificate.
SslPolicyErrors
Enumerates Secure Socket Layer (SSL) policy errors.
The host name is a domain name system (DNS) style host name.
The T:System.Security.Authentication.ExtendedProtection.ChannelBinding class encapsulates a pointer t...
static readonly Version Version11
Defines a T:System.Version instance for HTTP 1.1.
SocketOptionName
Defines configuration option names.
void SetTcpKeepAlive(bool enabled, int keepAliveTime, int keepAliveInterval)
Enables or disables the keep-alive option on a TCP connection.
X509Certificate ClientCertificate
Gets the last client certificate sent to the server.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
The notification failed for any reason.
Makes a request to a Uniform Resource Identifier (URI). This is an abstract class.
int IOControl(int ioControlCode, byte[] optionInValue, byte[] optionOutValue)
Sets low-level operating modes for the T:System.Net.Sockets.Socket using numerical control codes.
Manages the collection of T:System.Net.ServicePoint objects.
string Scheme
Gets the scheme name for this URI.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
delegate void AsyncCallback(IAsyncResult ar)
References a method to be called when a corresponding asynchronous operation completes.
AddressFamily AddressFamily
Gets the address family of the T:System.Net.Sockets.Socket.
void EndConnect(IAsyncResult asyncResult)
Ends a pending asynchronous connection request.
Implements the Berkeley sockets interface.
bool SupportsPipelining
Indicates whether the T:System.Net.ServicePoint object supports pipelined connections.
X509Certificate Certificate
Gets the certificate received for this T:System.Net.ServicePoint object.
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Defines the HTTP version numbers that are supported by the T:System.Net.HttpWebRequest and T:System....
static bool TryParse(string ipString, out IPAddress address)
Determines whether a string is a valid IP address.
int??? ConnectionLimit
Gets or sets the maximum number of connections allowed on this T:System.Net.ServicePoint object.
The exception that is thrown when a socket error occurs.
A type representing a date and time value.
bool UseNagleAlgorithm
Gets or sets a T:System.Boolean value that determines whether the Nagle algorithm is used on connecti...
int??? MaxIdleTime
Gets or sets the amount of time a connection associated with the T:System.Net.ServicePoint object can...
BindIPEndPoint BindIPEndPointDelegate
Specifies the delegate to associate a local T:System.Net.IPEndPoint with a T:System....
void Close()
Closes the T:System.Net.Sockets.Socket connection and releases all associated resources.
virtual ICollection Values
Gets an T:System.Collections.ICollection containing the values in the T:System.Collections....
Provides an Internet Protocol (IP) address.
IOControlCode
Specifies the IO control codes supported by the M:System.Net.Sockets.Socket.IOControl(System....
int ConnectionLeaseTimeout
Gets or sets the number of milliseconds after which an active T:System.Net.ServicePoint connection is...
SocketType
Specifies the type of socket that an instance of the T:System.Net.Sockets.Socket class represents.
bool Expect100Continue
Gets or sets a T:System.Boolean value that determines whether 100-Continue behavior is used.
static readonly Version Version10
Defines a T:System.Version instance for HTTP 1.0.
AddressFamily
Specifies the addressing scheme that an instance of the T:System.Net.Sockets.Socket class can use.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
virtual ICollection Keys
Gets an T:System.Collections.ICollection containing the keys in the T:System.Collections....
The exception that is thrown when an I/O error occurs.
SocketOptionLevel
Defines socket option levels for the M:System.Net.Sockets.Socket.SetSocketOption(System....
A database null (column) value.
Uri Address
Gets the Uniform Resource Identifier (URI) of the server that this T:System.Net.ServicePoint object c...
int ReceiveBufferSize
Gets or sets the size of the receiving buffer for the socket used by this T:System....
Represents the version number of an assembly, operating system, or the common language runtime....
Represents a chain-building engine for T:System.Security.Cryptography.X509Certificates....
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
WebExceptionStatus
Defines status codes for the T:System.Net.WebException class.
int CurrentConnections
Gets the number of open connections associated with this T:System.Net.ServicePoint object.
virtual Version ProtocolVersion
Gets the version of the HTTP protocol that the T:System.Net.ServicePoint object uses.
virtual byte [] GetRawCertData()
Returns the raw data for the entire X.509v3 certificate as an array of bytes.
virtual void Remove(object key)
Removes the element with the specified key from the T:System.Collections.Hashtable.
bool CloseConnectionGroup(string connectionGroupName)
Removes the specified connection group from this T:System.Net.ServicePoint object.
static DateTime Now
Gets a T:System.DateTime object that is set to the current date and time on this computer,...
Queue()
Initializes a new instance of the T:System.Collections.Queue class that is empty, has the default ini...
static bool OSSupportsIPv6
Indicates whether the underlying operating system and network adaptors support Internet Protocol vers...
virtual void Clear()
Removes all elements from the T:System.Collections.Hashtable.
Provides information about a specific culture (called a locale for unmanaged code development)....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
delegate IPEndPoint BindIPEndPoint(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
Represents the method that specifies a local Internet Protocol address and port number for a T:System...
bool IsBound
Gets a value that indicates whether the T:System.Net.Sockets.Socket is bound to a specific local port...
A conditional operation, such as a > b ? a : b in C# or If(a > b, a, b) in Visual Basic.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
Provides an HTTP-specific implementation of the T:System.Net.WebRequest class.
string ConnectionName
Gets the connection name.
string Host
Gets the host component of this instance.
Provides methods that help you use X.509 v.3 certificates.
Provides connection management for HTTP connections.
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Hashtable.
ProtocolType
Specifies the protocols that the T:System.Net.Sockets.Socket class supports.
void SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
Sets the specified T:System.Net.Sockets.Socket option to the specified integer value.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
static bool OSSupportsIPv4
Indicates whether the underlying operating system and network adaptors support Internet Protocol vers...