Intro To Network Programming 2008
Intro To Network Programming 2008
For instance:
• If the first bit in this field is 0 (zero), it is
referred to as a Class-A IP address.
• If the first two bits in this field are 10 , it is
referred to as a Class-B IP address.
• If the first three bits in this field are 110 , it
is referred to as a Class-C IP address.
0 31
Ver. IHL Type of Service Total Length
Identification Flags Fragment Offset
TTL Protocol Type Header Checksum
Source Address (32-bit)
Destination Address (32-bit)
Options+Padding
Payload Data
Payload Data
• Methods available:
• Windows NT Remote Procedure Call (RPC) <uses a
collection of libraries / tools with a focus on the
Application Procedure alone, targeting execution on
a remote machine, independent of transport
protocols>
• Windows Socket (WinSock) <uses Windows Socket
interface, extension of BSD Sockets, allows bi-
directional data-flow, upon completion of
asynchronous I/O, exports functions which transmit
messages to the relevant applications: feature fits
within the message-driven interface model of MS-
Windows>
• WinNet API <for over-the-MS-Windows-network
sharing of file-server / printer etc.>
19 (c) Dr. Rahul Banerjee, BITS-Pilani, India
Network Programming
in Linux / UNIX and similar
environments
» #include <sys/socket.h>
» struct sockaddr {
» unsigned short sa_family;
» char sa_data [MAXSOCKADDRDATA]
» }
#include <sys/socket.h>
The select () system call can also be made for determining if any connection request is
currently pending to a socket.
Similarly, a Client attempts to connect to a Client attempts to connect to a Server by creating a
socket, binding it to an address (optionally) and making the connect() call to the Server
at the known address.
24 (c) Dr. Rahul Banerjee, BITS-Pilani, India
A Glimpse of Address and Protocol
Families for Various Stacks
Address Families:
Unix / Linux Domain: AF_UNIX
TCP/IPv4 Domain: AF_INET
TCP/IPv6 Domain: AF_INET6
Novell NetWare Domain: AF_IPX
AppleTalk Domain: AF_APPLETALK
Protocol Families:
Unix / Linux Domain: PF_UNIX
TCP/IPv4 Domain: PF_INET
TCP/IPv6 Domain: PF_INET6
Novell NetWare Domain: PF_IPX
AppleTalk Domain: PF_APPLETALK
This problem may be easily taken care of if the programmer writes his
own function that extracts this data and its presentation format
and supplies it to the standard function.
There are numerous other similar situations in which such custom-
built functions, if written by the programmer, increase the level
of protocol independence of the resulting code. This, however,
comes with its own overheads and may not be a preferable
approach where speed and efficiency are the primary
requirements.