Domain Name Systems - Computer Programming - Lecture Notes, Study notes of Computer Engineering and Programming

Domain Name Systems, Well known Protocols, Windows Sockets, Basic Sockets Operations, Windows Socket Library, WinSock Initialization, Internet protocols, Server and client system. As you can see in this file, how descriptive above mentioned points are explained in this lecture of computer programming. VU is one of best university for computer science in our country.

Typology: Study notes

2011/2012

Uploaded on 11/06/2012

ahsen
ahsen 🇵🇰

4.6

(88)

84 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 27
27.1 INTRODUCTION 2
27.2 WELL KNOWN PROTOCOLS 2
27.3 DNS (DOMAIN NAME SYSTEMS) 2
27.4 WELL KNOWN HOST NAMES ON THE INTERNET 3
27.5 WINDOWS SOCKETS 3
27.6 BASIC SOCKETS OPERATIONS 3
27.7 WINDOWS SOCKET LIBRARY 4
27.8 WINSOCK INITIALIZATION 4
Example Code 6
SUMMARY 7
EXERCISES 7
pf3
pf4
pf5

Partial preview of the text

Download Domain Name Systems - Computer Programming - Lecture Notes and more Study notes Computer Engineering and Programming in PDF only on Docsity!

  • Chapter
  • 27.1 INTRODUCTION
  • 27.2 WELL KNOWN P ROTOCOLS
  • 27.3 DNS (DOMAIN NAME S YSTEMS)
  • 27.4 WELL KNOWN HOST NAMES ON THE INTERNET
  • 27.5 WINDOWS S OCKETS
  • 27.6 BASIC S OCKETS OPERATIONS
  • 27.7 WINDOWS S OCKET LIBRARY
  • 27.8 WINS OCK INITIALIZATION
  • Example Code
  • S UMMARY
  • EXERCISES

27.1 Introduction

Following are the some of the concept of packet information. These concepts will be used

in network programming.

• IP addresses and ports

• The structure of an IP packet

• Protocol

• Connection-oriented vs. datagram protocols

• IP, TCP and UDP

• HTTP, other wrapper protocols

27.2 Well known Protocols

Following are the well known protocols used today.

27.3 DNS (Domain Name Systems)

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 http://www.vu.edu.pk into addresses that the network can recognize ( 203.215.177.33 ).

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

Ports Name

80 http

25 SMTP

110 POP

43 WHOIS

53 DNS

21 FTP

27.7 Windows Socket Library

File Purpose

ws2_32.dll Main WinSock 2 DLL

wsock32.dll For WinSock 1.1 support, 32-bit applications

mswsock.dll MS extensions to WinSock

winsock.dll For WinSock 1.1 support, 16-bit applications

ws2help.dll WinSock2 helper

ws2tcpip.dll WinSock 2 helper for TCP/IP stacks

These files are windows socket libraries.

27.8 WinSock Initialization

The WSAStartup function initiates use of WS2_32.DLL by a process.

int WSAStartup( WORD wVersionRequested , /MAKEWORD(2,2)/ LPWSADATA** lpWSAData /*POINTER TO THE WSADATA structure );

wVersionRequested: Highest version of Windows Sockets support that the caller can use.

The high-order byte specifies the minor version (revision) number; the low-order byte

specifies the major version number.

lpWSAData: Pointer to the WSADATA data structure that is to receive details of the

Windows Sockets implementation.

Return Values: The WSAStartup function returns zero if successful. Otherwise, it

returns one of the error codes listed in the following.

An application cannot call WSAGetLastError to determine the error code as is normally done in Windows Sockets if WSAStartup fails. The WS2_32.DLL will not have been loaded in the case of a failure so the client data area where the last error information is stored could not be established.

Error code Meaning

WSASYSNOTREADY

Indicates that the underlying network subsystem is not

ready for network communication.

WSAVERNOTSUPPORTED

The version of Windows Sockets support requested is not

provided by this particular Windows Sockets

implementation.

WSAEINPROGRESS A blocking Windows Sockets 1.1 operation is in progress.

WSAEPROCLIM

Limit on the number of tasks supported by the Windows

Sockets implementation has been reached.

WSAEFAULT The lpWSAData is not a valid pointer.

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.

App versions DLL versions

wVersion

requested

wVersion

wHigh

version

End result

1.1 1.1 1.1 1.1 1.1 use 1.

1.0 1.1 1.0 1.1 1.0 1.0 use 1.

1.0 1.0 1.1 1.0 1.0 1.1 use 1.

1.1 1.0 1.1 1.1 1.1 1.1 use 1.

1.1 1.0 1.1 1.0 1.0 Application fails

1.0 1.1 1.0 --- --- WSAVERNOTSUPPORTED

1.0 1.1 1.0 1.1 1.1 1.1 1.1 use 1.

1.1 2.0 1.1 2.0 1.1 1.1 use 1.

2.0 2.0 2.0 2.0 2.0 use 2.

WinSock version: high-order byte specifies the minor version (revision) number; the low-

order byte specifies the major version number.

Summary

Socket is important in an inter-process communication. Sockets are more reliable

and secure. Socket version 2 is used these days. In windows, sockets are started using

WSAStartup API. WSAStartup API starts and initializes Windows Sockets. 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.

Exercises

1. Study internet protocols by yourself.