Skip to main content

How to do Socket Programming in Computer networks ?

Socket Programming:



"An application programming interface (ATI) use for interprocess communication (IPC). A well defined method of connecting two process locally or across a network it is protocol and language interdependent and often referred as Berkeley socket or BSD Socket."









Socket is protocol independent method of creating a connection between processes Socket can be either connection based or connection pocket based or streams based reliable or unreliable.




Socket Characteristics:

Sockets are characterized by their domain type and transport protocol common are
AF UNIX- Address format is UNIX path name.
AF INET- Address format is host and port number.

Common types are
  A)     Virtual circuit: received in order transmitted and reliability    
  B)     Data gram: arbitrary order unreliable each socket type has one or more protocol
a)      TCP/IP
b)      UDP


Use Of Sockets

I Connection based socket communicate silent server waits for a connection silent server connection less socket are peer to peer each process is symmetric
This list is a summary of function or methods provide by the berkets sockets API library  
1)      Socket create a new socket type identify by an integer number and allocates system resource to it.
2)      Bind is typically use on the server side and associates a sockets with a socket address structure specified local port number and IP address.
3)      Listen is use on the silent side and assign a free local part no to socket in case of TCP socket to enter listing state
4)      Connect is use on the silent side assignment a free local part no to a socket in case of  TCP socket if cause an attempt to established a TCP connection
5)      Accept  is used on the server side it accepted a receive incoming attempt to create a new TCP connection from the remote to create a new socket associate with the socket address pair this connection
6)      Send and receive or read write or send to and received form are used for sending and receiving data to from a remote socket.
7)      Close cause the system to release resources allocated to socket in case TCP the connection is terminated
8)      Get host by address  & get host by name are used to resolve host name a address IP V4 only
9)      Select is used to Pune a provided list of sockets for those that are ready to read, ready to  write or that have error.
10)  Poll is used to check on the state of socket of socket in set of socket the set can be tested to see if any socket can  be written to read from or if an error occurred
11)  Get sock opt is used to retrieve the current value of a particular socket option for the specified socket.
12)  Set sock opt is used to set a particular socket option for the specified socket.


Client server example using TCP

The transmission control protocol TCP is a connection – oriented protocol that provides a variety of error correction & performance feature for transmission of byte stream. A process- INNET, PF – INET6, the socket made for stream ssockets ( sock- STREAM), & the IP protocol identifier for TCPC(IP PROTO-TCP)


Server

Setting up a simple TCP server involves the following steps
Creating a TCP socket with a call to socket binding the socket to the listen part with a call to bind before calling blind a Programmer must clear a scokaddr- in structure , Clear it with memset c & the sin family (AF-INET), & fill its sin – port ( the listening port, in network byte order fields. Converting a short int to network byte order can be done by calling the function h tons() ( host to network listen. Accepting incoming connection, via a call to accept. This blocks until an incoming connection is received and then return a socket description for the accept can be called again at any time with this socket, until it is closed. Communicating with the remote host, which can be done through send and receive or write and read. Eventually closing each socket that was opened, once it is no longer needed, using close.



Client

Programming a TCP client application involves the following steps:
1        Creating a TCP socket, with a call to socket.
2        Connection to the server with a call the use of connect passing a sockaddr_ in structure with the sin family set to AF_INET, sin port set to the port the end point is listening (in n/w byte order), & sin _ addr set to the IP addr of listening server (also in n/w byte order), & sin _ addr set to the IP addr of listening server (also in n /w byte order).
3        Communicating with the server by using send & receive or write & read.
4        Terminating the connecting & cleaning up with a call to close.


Basics of Multiplexing

Difference between Multiplexing and Multiple Access

Comparison in FDM and synchronus TDM and statistical TDM

How Multiplexing of signals in Fiber Optical cable is done?

Popular posts from this blog

Multiplexing and Multiple Access

Multiplexing And Multiple Access : Digital Communications Difference between Multiplexing and Multiple Access: Sr.No. Multiplexing Multiple Access 1 “In telecommunications and  computer networks, multiplexing is a process where multiple analog  message signals or digital data  streams are combined into one   signal over a shared medium.” “In telecommunications and computer networks, a channel access method or multiple access  method allows several terminals connected to the same multipoint physical medium to transmit over it and to share its capacity.” 2 The multiplexed signal is transmitted  over a communication channel,  which may be a physical transmission medium. A channel-access scheme is  based on a multiplex method  that allows several data streams  or signals to share the  same communication channel or  physical media.

Difference in between Time division multiplexing (TDM) and Frequency division multiplexing (FDM)

Difference in between TDM and FDM: This page on FDM versus TDM describes  difference between FDM and TDM multiplexing . FDM is the short form of frequency division multiplexing and TDM is the short form of time division multiplexing. In FDM each signal is modulated onto different unique RF carrier frequency and all carrier frequencies are separated significantly so that bandwidth of the signals do not overlap in frequency domain. Figure: Difference in between TDM and FDM

Comparison between armature controlled and field controlled DC servo motor

Comparison between armature controlled and field controlled DC servo motor : Field controlled DC servomotor Armature controlled DC servomotor 1.                         Field is excited by control voltage Armature is excited by control voltage 2.                        Armature            current kept constant Field      current kept constant 3.                        Required             low        power amplifiers are simple to design Required             high       power amplifiers 4.                        Efficiency is poor Efficiency is better 5.                        It has large time constant It             has         small      time constant 6.                        Cost is low Cost is high 7.                        It is open loop system It is close loop system Comparison between ar