



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Domain Name System (DNS), the locator service of choice in Microsoft® Windows®, is an industry-standard protocol that locates computers on an IP-based network. IP networks such as the Internet and Windows networks rely on number-based addresses to process information. Users however, are better at remembering letter- based addresses, so it is necessary to translate user-friendly names into addresses that the network can recognize
Domain Name System, DNS, is an industry-standard protocol used to locate computers on an IP-based network. Users are better at remembering friendly names, such as www.microsoft.com or msdn.microsoft.com, than number-based addresses, such as 207.46.131.137.
IP networks, such as the Internet and Microsoft® Windows® 2000 networks rely on number-based addresses to ferry information throughout the network; therefore, it is necessary to translate user-friendly names (www.microsoft.com) into addresses that
the network can recognize (207.46.131.137). DNS is the service of choice in Windows 2000 to locate such resources and translate them into IP addresses.
DNS is the primary locator service for Active Directory, and therefore, DNS can be considered a base service for both Windows 2000 and Active Directory. Windows 2000 provides functions that enable application programmers to use DNS functions such as programmatically making DNS queries, comparing records, and looking up names.
Windows Sockets (Winsock) enables programmers to create advanced Internet, intranet, and other network-capable applications to transmit application data across the wire, independent of the network protocol being used. With Winsock, programmers are provided access to advanced Microsoft® Windows® networking capabilities such as multicast and Quality of Service (QOS).
Winsock follows the Windows Open System Architecture (WOSA) model; it defines a standard service provider interface (SPI) between the application programming interface (API), with its exported functions and the protocol stacks. It uses the sockets paradigm that was first popularized by Berkeley Software Distribution (BSD) UNIX. It was later adapted for Windows in Windows Sockets 1.1, with which Windows Sockets 2 applications are backward compatible. Winsock programming previously centered on TCP/IP. Some programming practices that worked with TCP/IP do not work with every protocol. As a result, the Windows Sockets 2 API adds functions where necessary to handle several protocols.
The WSAStartup function must be the first Windows Sockets function called by an application or DLL. It allows an application or DLL to specify the version of Windows Sockets required and retrieve details of the specific Windows Sockets implementation. The application or DLL can only issue further Windows Sockets functions after successfully calling WSAStartup.
In order to support future Windows Sockets implementations and applications that can have functionality differences from the current version of Windows Sockets, a negotiation takes place in WSAStartup. The caller of WSAStartup and the WS2_32.DLL indicate to each other the highest version that they can support, and each confirms that the other's highest version is acceptable. Upon entry to WSAStartup , the WS2_32.DLL examines the version requested by the application. If this version is equal to or higher than the lowest version supported by the DLL, the call succeeds and the DLL returns in wHighVersion the highest version it supports and in wVersion the minimum of its high version and wVersionRequested. The WS2_32.DLL then assumes that the application will use wVersion If the wVersion parameter of the WSADATA structure is unacceptable to the caller, it should call WSACleanup and either search for another WS2_32.DLL or fail to initialize.
It is legal and possible for an application written to this version of the specification to successfully negotiate a higher version number version. In that case, the application is only guaranteed access to higher-version functionality that fits within the syntax defined in this version, such as new Ioctl codes and new behavior of existing functions. New functions may be inaccessible. To get full access to the new syntax of a future version, the application must fully conform to that future version, such as compiling against a new header file, linking to a new library, or other special cases.
This negotiation allows both a WS2_32.DLL and a Windows Sockets application to support a range of Windows Sockets versions. An application can use WS2_32.DLL if there is any overlap in the version ranges. The following table shows how WSAStartup works with different applications and WS2_32.DLL versions.
Example Code
WORD wVersionRequested; WSADATA wsaData; int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData ); if ( err != 0 ) { /* Tell the user that we could not find a usable / / WinSock DLL. */ return; }
/* Confirm that the WinSock DLL supports 2.2./ / Note that if the DLL supports versions greater / / than 2.2 in addition to 2.2, it will still return / / 2.2 in wVersion since that is the version we / / requested. */
if ( LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 2 ) { /* Tell the user that we could not find a usable / / WinSock DLL. */ WSACleanup( ); return; }
/* The WinSock DLL is acceptable. Proceed. */
Once an application or DLL has made a successful WSAStartup call, it can proceed to make other Windows Sockets calls as needed. When it has finished using the services of the WS2_32.DLL, the application or DLL must call WSACleanup to allow the WS2_32.DLL to free any resources for the application.
Details of the actual Windows Sockets implementation are described in the WSADATA structure.
An application or DLL can call WSAStartup more than once if it needs to obtain the WSADATA structure information more than once. On each such call the application can specify any version number supported by the DLL.
An application must call one WSACleanup call for every successful WSAStartup call to allow third-party DLLs to make use of a WS2_32.DLL on behalf of an application. This means, for example, that if an application calls WSAStartup three times, it must call WSACleanup three times. The first two calls to WSACleanup do nothing except decrement an internal counter; the final WSACleanup call for the task does all necessary resource deallocation for the task.