Monday, January 31, 2011

Windows Sockets

Windows under network programming specifications - Windows Sockets under Windows widely applied, open, supports multiple protocol network programming interface.

introduction

From 1991 to 1995 version 1.0 2.0.8 edition, after continuous perfecting and in the Intel, Microsoft, from, SGI Novell Informix, etc, the full support of the company, has become the Windows of the DE facto standard network programming.

The Windows Sockets norms

In Berkeley university BSD UNIX U.C. popular in Socket interface as examples, defines a set of Microsoft Windows under network programming interface. It includes not only the people are familiar with the Berkeley Socket style library function, Also includes a group for Windows extension library function, so that the programmer can fully USES Windows news drive mechanism for programming. The Windows Sockets regulating intention is to provide application developers a simple set of apis, and let each network software vendors to comply. In addition, in a particular version of Windows, on the basis of the Windows Sockets also defines a binary interface (ABI) to ensure application Windows Sockets API application can in any network software vendors with Windows Sockets work on the implementation of the protocol. Therefore the standard defines application developers can use, and network software vendors can realize a set of library function calls and related semantics. Keep the Windows Sockets standard network software, which we call Windows Sockets compatible, and Windows Sockets implementation provider, we call Windows Sockets provider. A network software vendors must be 100 per cent to realize Windows Sockets norms to do now Windows Sockets compatible. Any can with Windows Sockets implementation collaborative working application is considered with Windows Sockets interface. We call this application for Windows Sockets applications. The Windows Sockets standard definition and records the how to use the API and Internet protocol clan (IPS, usually we mean the TCP/IP) connected, especially must be pointed out that all the Windows Sockets implementation supports streaming socket and data submitted to set of interfaces. Application procedure call Windows Sockets API realize mutual communication. The Windows Sockets and use a layer of network communication protocol functions and operating system calls achieve actual communications work. The relations between them as shown in the diagram

Communication foundation: set of interfaces

Communication is the basis of Socket (Socket), a Socket is communication end. In the end, you can find a corresponding a name. A being used socket has its type and related process. Socket exists in communication domain. Communication domain is to treat common thread through socket communication and to introduce an abstract concept. Socket usually and the same domain socket exchange data (data exchange may also cross domain boundaries, but this time must perform an explanation program). The Windows Sockets standard support single communication domain, which is the Internet domain. Various process using this domain between each other with Internet protocol clan to communicate (Windows Sockets 1.1 above version to support other fields, such as Windows Sockets 2). Set of interfaces can be classified according to communication properties, This nature is visible to the user. Applications are usually only in the same kind of socket communication between. But as long as the underlying communication protocol allows, different types of set of interfaces between likewise also can communications. Users can use at present two sets of interface, namely flow set of interfaces and data submitted to set of interfaces. Flow socket provides bidirectional, orderly, no repetition and no record of data flow service boundary. Data submitted to socket support two-way flow of data, but does not guarantee is reliable, orderly, no repetitive. That is to say, one from the data submitted to socket receiving information process likely find information repeated, or when the goods are dispatched the order of different. Data submitted a socket important characteristic is its retained record boundary. For this one characteristic, data submitted to socket adopted and now many packet switching network (such as Ethernet) is very similar to the model.

Client/server model

A distributed applications in establishing the example is most often client/server model. In this scheme in client applications to server program to request service. This way the implied in establishing a client/server communication between the asymmetry. Client/server model work requires a consensus for the server and the client to ensure that the convention services can be provided (or accepted). This includes a set of practices has a set of protocols. It must be in communications at the ends of were met. According to different actual situation, agreement may be symmetrical or asymmetrical. In a symmetrical agreements, each party may play a master-slave roles, In asymmetric agreement, one party is invariably considered host, and the other side is from the machine. A symmetric agreement example is used in the simulation of the Internet terminals TELNET. And asymmetric agreement example is the Internet FTP. Whatever specific agreement is symmetrical or asymmetrical, when the service is provided inevitable existence "client process" and "service process." A service programs usually in a well known address to the service request monitor, i.e., service process has been dormant until a customer for this service address puts forward the connection attempt. At this time, service program is "waking" and to provide services to the customer request - appropriate responses. This is a request/corresponding process can be simple graphic. Although connection-oriented services is to design a client/server application standards, but some service is also can pass data submitted to set of interfaces provide.

Through the data submitted to socket send broadcast packets

Data submitted to set of interfaces can be used to many systems support network send broadcast packets. To implement this function, the network itself must support broadcasting function, because the system software does not provide any simulation for broadcasting function. Broadcast information will give the Internet causes very heavy burden, because they need network on each machine hosts are for their services, so send broadcast packets ability is limited to those with explicit marks the radio interface allows the set. Radio is usually in order to use the following two reasons: 1. An application hope in local networks to find a resource, with the application of the resources of the address again without any priori knowledge. 2. Some important functions, such as routing information request them to send all can find the neighborhoods of machine. The destination address is broadcast information depends on this information will be in what network on a radio. Internet domain to support a shorthand address used to broadcast - INADDR_BROADCAST. Because of using broadcast before a data submitted must be bound of interface, so all receive broadcast message contains the sender's address and port.

The Intel microprocessor with Windows Sockets function relationship

The Intel microprocessor byte order is DEC VAX processor bytes and consistent in order. So it with 68000 type processor and the Internet order is different, so the user when use to be very careful to ensure the correct order. Any from Windows Sockets function of IP address and port of quotes, and transmitted to the Windows Sockets function of the IP address and port all is according to the order of network organization, which also includes a sockaddr_in structure this data types of IP address domain and port domain (but not including sin_family domains). Considering an application usually use and "time" service corresponding port to connect the server, and if the server to provide a certain mechanism to notify users use another port. Therefore getservbyname () function returns the socket is already network order, can be directly used in composition an address, without the need for conversion. However, if the user input a number, and designated use this end slogans, applications must be in use it establish address before it from host sequence, convert network order (using htons () function). Accordingly, if the application want to show that contained in a certain address the socket (for example from getpeername () function returns the), this end slogan must be displayed ago from network order to convert to host order (using ntohs () function). Because the Intel microprocessor and Internet byte sequence is different, the transformation is inevitable, the application of the writers should use as Windows Sockets API part of the standard conversion functions, but do not use your own conversion function code. Because the future of Windows Sockets realization are likely in host byte sequence and network byte orders the same machine operation. Therefore only use the standard conversion function applications are portable.

No comments:

Post a Comment