This article focuses on the use of Microsoft's DOTNET platform for network-related winformProgramDevelopment.
In the. NET platform, network-related content is basically included in the namespace system. net.
On msdn, Microsoft provides the following optimization suggestions:
Use as much as possibleWebrequestAndWebresponseInstead of converting the data typeChild class. Applications that use webrequest and webresponse can use the new Internet protocol without a wide range of code changes, facilitating smooth upgrade.
When using the system. Net class to write ASP. NET applications running on the serverGetresponseAndGetresponsestreamThe Asynchronous Method is usually better. This article also applies to the Development of Windows programs. In order to avoid Main UI blocking and improve ue, asynchronous mode is also a better choice.
The number of connections opened for Internet resources may significantly affect network performance and throughput. By default, system. net uses two connections for each application on each host. Set the connectionlimit attribute in the servicepoint of the application to add this number to a specific host. Set servicepointmanager. defaultpersistentconnectionlimit to add this default value to all hosts.
When writing socket-level protocols, try to use tcpclient or udpclient instead of writing directly to the socket. These two client classes encapsulate the creation of TCP and UDP sockets without the need to process the connection details.
When accessing the site or application that requires creden。, use the credentialcache class to create a credential cache instead of providing them for each request. The credentialcache class searches for cache to find the appropriate creden。 to be provided to the request, so that you do not have to create and provide creden。 Based on the URL.
06a8cfe2