Socket Programming
Socket Programming
Programming
160122733303
Socket Programming
It is a way to enable communication between two devices (typically a client and a server)
over a network. A socket provides an endpoint for sending or receiving data across the
network, using standard network protocols like TCP (Transmission Control Protocol) or UDP
(User Datagram Protocol).
The server program listens for client requests and processes them.
The client program initiates a connection to the server by specifying
the server's IP address and port number.
Steps Involved in Socket Programming
C o m m u n i c a t io n :
U s e re a d ()/re c v () to re c e iv e d a ta f ro m th e c lie n t an d w r ite () / s e n d ( ) to s e n d
d a ta b ac k .
C lo sin g t h e So c ket :
C lo s e th e c o n n e c tio n u s in g c los e ().
•
Socket Creation:
Create a socket using socket().
Connecting:
Connect to the server using connect() by providing the server's IP address and port.
Communication:
Use send() to send data to the server and recv() to receive data.