Lab 6

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name: Basant Adhikari Date: 2022 Feb 2

Roll no: 180104


Faculty: IT
Lab6:
 Title: INTRODUCTION TO WINDOWS SOCKET PROGRAMMING
 Objectives:
1. To be familiar with WINSOCK programming.
2. To write a simple winsock programming file.
 Theory:
Windows Socket API, also known as Winsock, is a type of application programming
interface (API) used to communicate between Windows network software and network
services. It is primarily based on Transmission Control Protocol/Internet Protocol
(TCP/IP), and derives its roots from the Berkeley Unix sockets interface.
Socket programming shows how to use socket APIs to establish communication links
between remote and local processes. The processes that use a socket can reside on the same
system or different systems on different networks. Sockets are useful for both stand-alone
and network applications.
Windows sockets API (WSA) is the technical specification for Windows sockets. It
includes the Berkeley socket-style routines as well as a set of Windows-specific
extensions. Windows sockets provides a standard interface between Windows TCP/IP
client applications and the underlying TCP/IP protocol suite.
Advantages of WSA are:
1. Open Standard: open standard make technology accessible and provide
other benefit as well. It provides a well-defined interface so that one
vendor’s product can interoperate with another’s.
2. Source code portability
3. Support Dynamic Linking

 Discussion and Practice:


To create a basic winsock program
1. Create a new empty project.
2. Add an empty C++ source file to the project.
3. Ensure that the build environment refers to the Include, Lib, and Src directories of
the Microsoft Windows Software Development Kit (SDK) or the earlier Platform
Software Development Kit (SDK).
4. Ensure that the build environment links to the Winsock Library file Ws2_32.lib.
Applications that use Winsock must be linked with the Ws2_32.lib library file.
The #pragma comment indicates to the linker that the Ws2_32.lib file is needed.
5. Begin programming the Winsock application. Use the Winsock API by including
the Winsock 2 header files. The Winsock2.h header file contains most of the
Winsock functions, structures, and definitions. The Ws2tcpip.h header file
contains definitions introduced in the WinSock 2 Protocol-Specific Annex
document for TCP/IP that includes newer functions and structures used to retrieve
IP addresses.

You might also like