Win32 programming network communication

zhaozj2021-02-17  72

Win32 programming network communication 5/31/2001 11: 58: 24 · · QQ new human compilation ·· Yesky 1 2 3 4 5 6 7 Next This article will introduce the network communication supported by the existing Win32 function Function and show how to use them in your own app. In the API, there are two ways to support network communication: mailslot and name pipes. This article will discuss them separately and introduce their advantages and disadvantages. Because Win32 APIs support network communication, it is particularly simple to create various applications of various networking. For example, you have to build a multi-user conferencing system in your network, similar to "CB" of BBS. In this system, users run a conference system program on their respective machines, all of the information they play will broadcast all other users of the same network. Usually this system can be implemented using Mailslots because Mailslots is easy to broadcast information. In fact, multiplayer online games are also similar techniques. When you want to transfer a large number of data flow between the two machines, you usually use the naming point of the point-to-point point. For example, you will use a naming pipe to implement a network digital phone or video system. Customer / server is also using named pipes. One of the central machines will be used as the server, and then all other clients can use the named pipe to connect to it. In order to better understand the following examples, the web foundation is necessary. The figure below shows a simple network in a small company. Each machine uses a network adapter to connect to the network and has a unique name to identify it. The network adapter determines the type of network, common Ethernet or token network. The adapter also determines the media used in the network, which can be coaxial, twisted pair, etc. It is to know that in such a simple network, all machines can communicate equally equally with other machines. **************** Figure 1 *********************** Via the traditional Win32 There are two ways to communicate between machines. One is mailslot, one machine can broadcast a message, and all other machines in the network can be received. When nameless, one machine selects another communication and establishes a special connection with it. The benefits of named pipes are reliable connection. If the connection is interrupted, such as a network card or a network line fails, both ends of the connection can be immediately received information. Mailslots is unreliable because the sender cannot confirm if the recipient has received information. The advantage of mailslot is that it can easily send a number of machines to many machines. The figure above shows a network segment. The definition of a network segment is a set of machines directly connected to each other. The number of machines in a network segment is limited, because when the number of machines increases, the network traffic will increase. The usual limit is approximately 100 machines. In a large company, approximately 20 to 30 machines per network segment. All network segments can be connected via the router so that they can communicate between them, as shown below. It is important to understand this difference, because usually a mailslot message can only be transmitted in a network segment, and information of the named pipe can be transmitted to another network segment through the router. ***************** Figure two *************************************** Network communication, there are three different communication methods: broadcast, point-to-point, and client / server. When using the MAILSLOT application in the broadcast mode, a machine sends information to all other machines on the network segment. At point-to-point communication, a machine establishes a special connection with another, and the data can be reciprocated between them through a naming pipe. In a client / server relationship, a machine is used as a server, and all machines are connected to it by a point-to-point named pipe.

转载请注明原文地址:https://www.9cbs.com/read-30904.html

New Post(0)