We have described the implementation of the Visual C # UDP protocol in detail, so we do not know whether you are clear about the use of classes. Here we will analyze the architecture and functions of the time system over the Visual C # UDP protocol network.
Visual C # Implementation of UDP protocol-Architecture and functions of the network-to-time system:
There are a lot of applications in the LAN. to work collaboratively, you need to ensure that the time on the client is consistent. To achieve this, the common practice is that the client reads the time from a server with a relatively correct time, in this way, the local time is corrected. For example, the GPS timing system is often seen. In this section, the main function of the timing system on the LAN is to ensure the unification of the computer time and date on the LAN 。 when the network is connected, the program is divided into two parts: the server-side program and the client-side program, the specific method is: in the same network segment, a computer is fixed as the server at the time of access. All computers in this network segment can read the time and date on this server, the local time and date are determined based on the time and date on the server. on the server side, the program needs to achieve the following functions:
Can receive requests from any client in the LAN
Record the computer name and time of the Request Client
Accurate server sending time and date
To achieve the following functions:
Server host or IP address can be set
The time and date information sent by the server
The local time can be corrected based on the received server time and date.
Therefore, when you use Visual C # UDP to implement network-to-system access, there are two parts: the server-side program and client program. Next we will first introduce the specific steps of the server-side program in the system when implementing the network pair in Visual C 。
Visual C # The specific steps for implementing the server-side program of the system during network peer access using UDP:
The server-side program is relatively simpler than the client program, mainly because the work of the server-side program is relatively simple
It is the time data of receiving client-side requests and sending server-side requests. In addition, the client must not only send and receive data, but also extract the server-side time, in this way, modify the time and date of the local computer. The following describes how to use Visual C # To implement the server-side program of the system when the network is connected 。
1. Start Visual Studio. Net 。
2. Select menu File> New> project. The new project dialog box is displayed 。
3. Set the project type to Visual C # project ]。
4. Set the template to a Windows application ]。
5. Enter the UDP peer server in the name text box ]。
6. In the "location" text box, enter E: \ VS. NET project, and click OK.
7. In the Solution Explorer window, double-click the Form1.cs file To Go To The Form1.cs file editing page 。
8. At the beginning of the Form1.cs file, use the following imported namespace code to replace the default imported namespace code 。
- using System ;
- using System.Drawing ;
- using System.Collections ;
- using System.ComponentModel ;
- using System.Windows.Forms ;
- using System.Data ;
- usi