Please enable JavaScript.
Coggle requires JavaScript to display documents.
SOCKET PROGRAMMING (Addressing (Network address is used to identifier a…
SOCKET PROGRAMMING
Addressing
Network address is used to identifier a machine within a network
Internet addressing or mostly known as IP address
IP address consists of 4 decimal numbers and separated by dot
-102.111.98.1
UNIX networking system calls cannot deal with this IP address directly
Need to do conversion
Introduction
IPC is the communication between processes within a system
For networked environment, networked client server basis is needed
For sharing of information/resources such as files, disk space, processors and peripherals
In networked client server, client machine is one machine and server machine is another machine
Sockets
Sockets are the traditional UNIX interprocess communication mechanism that allows processes to talk to each other, even if they’re on different machines.
Common uses of sockets include:
transferring data from one machine to another machine
transferring voice/video from one machine to another machine
transferring files from one machine to another machine
printing a file on one machine from another machine
Process communication via sockets is based on the client-server model: email (SMTP, IMAP, POP), Web (HTTP), file transfer (FTP, scp), remote login (telnet, ssh), network management(SNMP), network operation (DNS, BGP, OSPF), VoIP (SIP), etc., etc.
One process, known as a server process, creates a socket whose name is known by other client processes.
Types of Connection
Connection oriented model
Also known as virtual circuit model
Used for sending to a same constant of destination
Example: Remote login connection
Metaphor
-Like phone network
-Ordering of messages and acknowledgements (reply)
Connectionless oriented model
Used for sending broadcast to many clients
Is not concerned that the clients receive the message
Example: Server broadcasts message to its clients
Metaphor:
-Sending letter via postal service
-No guarantee recipient will receive
To establish any communication, client and server need to be connected at:
Hardware level
Equipment like cables, cards, routers etc
Software level
Networking protocols
Protocols
Transmission Control Protocol (TCP) for connection oriented model
User Datagram Protocol (UDP) for connectionless oriented model
Ports
After knowing which machine to communicate, then which channel to connect is required
This channel is know as port
Server will listens for the connection on a specified port number
A connection must have IP and port number
Typical Steps in Server and Client
an overview of a server:
creating a server socket
naming a server socket
specifying the maximum number of pending connections to a server socket
accepting connections on a server socket
serving a client
an overview of a client:
creating a client socket
connecting a client socket to the server socket
communicating via sockets
What is a socket?
An interface between application and network
The application creates a socket
The socket type dictates the style of communication
-- reliable vs. best effort
-- connection-oriented vs. connectionless
Once configured the application can
pass data to the socket for network transmission
receive data from the socket (transmitted through the network by some other host)