Visual C # .Net web application development -Tcp papers (1) Author: Song Hua www.ASPCool.com time: 2002-5-5 17:34:23 Views: 8506
The previous "Visual C # .NET Network Program Development-Socket" said: Support HTTP, TCP and UDP classes constitute an intermediate layer of TCP / IP three-layer model (request response layer, application protocol layer, transport layer) - Application Protocol layer, the class of the layer provides a higher level of abstraction than at the bottom of the Socket class, which encapsulates the creation of TCP and UDP sockets, does not need to handle the details of the connection, which makes us in writing socket level Attempts, you can try more to use TcpClient, udpclient, and tcplistener more, not directly to the Socket. This level of relationship between them is as follows: It can be seen that the TCPClient class is based on the Socket class, which is the basis for providing TCP services at a higher abstraction. Because of this, communication protocols on many application layers, such as FTP (File Transfer "file transfer protocol, HTTP (Hypertext TransferS Protocol) hyper text transfer protocols, etc., are directly above TCPClient. The TCPCLIENT class uses TCP request data from the Internet resource. The TCP protocol establishes a connection with the remote endpoint and then uses this connection to send and receive the packet. TCP is responsible for ensuring that the packet is sent to the endpoint and combined in the correct order when the packet arrives. From the name, you can see that the TCPClient class is designed for the client, which provides a client connection for TCP network services. TCPClient provides a simple way to send and receive data over a network connection. To establish a TCP connection, you must know the address (iPadDress) of the network device that carries the required service, and the TCP port (Port) of the service for communication. Internet Assigned Numbers Authority (IANA) Defines the port number of public services (you can access http://www.iana.org/assignments/port-numbers to get more detailed information). The services in the IANA list can use the port numbers in this range of 1,024 to 65, 535. To create this connection, you can use one of the three constructor of the TCPClient class: 1. Public TCPCPClient () When using this constructor with any parameters, the default IP address will be used and will be used by default. Communication port number 0. In this case, if the unit does not stop an IP address, it will not be possible to choose. The following statement exemplifies how to create new TCPCPClient: TcpClient tclientc = new tclient (); 2, public tclient (ipendPoint) uses native IpendPoint instance objects to create TCPClient. The previous introduction, IpendPoint expands the network endpoint as the IP address and port number, which is used to specify the local network interface (IP address) and port number used when establishing a remote host connection, this constructing method is used This machine ipaddress and port provide room for selection.