Visual C # Introduction to UDP inter-network time System

Source: Internet
Author: User

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 。

 
 
  1. using System ;   
  2. using System.Drawing ;   
  3. using System.Collections ;   
  4. using System.ComponentModel ;   
  5. using System.Windows.Forms ;   
  6. using System.Data ;   
  7. usi  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.