Microsoft's Windows Sockets API is a web application interface under Windows. In order to apply for message mechanisms under Windows and asynchronous I / O selection operations, the Windows Sockets API is functionally expanded to have nearly 20 functions, with the expansional part of the crown. It fully embodies the advantages of WidNows with the prefix WSA (Windows Sockets asynchronous), such as WSAStartup, WSACLEAN, etc. In addition, the Windows Sockets API has a 16-bit and 32-bit edition. The 16-bit version is a single trip, and the 32-bit version provides a multi-threaded security. Microsoft Visual Basic provides available controls for Windows Sockets - Winsock controls. This control provides users with extremely convenient ways to access TCP and UDP networks. And suitable for many visual environments such as Microsoft Access, Visual Basic, Visual C , and Visual FoxPro. The C / S program is prepared by the Winsock control, and the programmer does not need to understand the details of the TCP or low-level Winsock APIS calls, such as the user who does not need to consider the network byte order and the native sequence of data can be transmitted directly. It is extremely convenient to implement network process communication with this control. In TCP applications, in order to establish a network connection instance (instance) server side, simply set the local service port number, then the server call method Listen enters the blocking state, waiting for the connection request from the customer. The client corresponding to this should not only set the Winsock's property Remotehost to the server's name (IP address or network code), but also set the port number (Remoteport) of the corresponding service listening to the server, such as the FTP service at the 21st port. HTTP is at the port of 81, etc. Then call the method Winsock.Connect to issue a request to the server. When the server receives the customer request, the event connectionRequest will be triggered. If the server is willing to provide services, you can call the Accept method to accept the connection. Once the connection is established, both ends can be transmitted or received using SendData or GETDATA. Event DataArrival will be triggered when the other end data is ready. The implementation of the UDP protocol is different from TCP. The data can be transmitted without establishing a connection at both ends of the SOCKETS. Therefore, a UDP application can serve as a server or customer role. The following program code is the basic framework for Visual Basic Windows Sockets.