0% found this document useful (0 votes)
8 views11 pages

DCOMS Week 7 Socket Programming

Uploaded by

code.binay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

DCOMS Week 7 Socket Programming

Uploaded by

code.binay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Distributed Computer

Systems
CT024-3-3-DCOMS and VE

Socket Programming

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 1


TOPIC LEARNING OUTCOMES

At the end of this topic, you should be able to:

•Understand Socket Programming

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 2


Teaching Contents

• Socket Programming
– Introduction
– Working Principle
– Implementation

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 3


What is Socket
Programming?

Java Socket programming is used for communication between the applications


running on different devices.

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 4


Socket Programming- Working Principle

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 5


Socket Programming- Working Principle

In socket programming, there 1.Create a socket: In your programming


are two types of sockets: server language of choice (such as Python or
sockets and client sockets. The Java), you create a socket object that
server socket listens for represents a network endpoint. The
incoming connections from socket object can be either a server
clients, while the client socket socket
2.Bind (fororservers):
a client socket.
If you're creating a
initiates a connection to the server application, you need to bind the
server. Here are the basic steps server socket to a specific IP address and
involved in socket port number on the machine where the
programming: server is running. This allows the server
socket to listen for incoming connections on
that address
3.Listen and port.After binding, the
(for servers):
server socket enters a listening state,
waiting for incoming connection requests
from clients.

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 6


Socket Programming- Working Principle
4.Connect (for 5.Accept (for servers): 6.Send and receive
clients): If you're When a client data: Once the
creating a client attempts to connect connection is
application, you need to the server, the established, both the
to connect the client server socket accepts client and server
socket to the IP the connection sockets can send and
address and port request, creating a receive data using
number of the server new socket methods or functions
to which you want to specifically for that provided by the
7.Close the sockets: After
connect. client. This new socket library. Data
communication is complete, socket is used for can be sent in the
both the client and server communication with form of bytes or
sockets should be closed to the client. encoded strings.
release the resources.
Closing the socket
terminates the connection.

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 7


Socket Programming- Implementation

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 8


Review Questions

• What is Socket Programming?


• Briefly outline the working principle of Socket programming.

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 9


Summary / Recap of Main Points

• Introduction to Socket Programming


• Working Principle
• Implementation

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 10


What To Expect Next Week

In Class
• Multithreading

CT024-3-3 Distributed Computer Systems Socket Programming SLIDE 11

You might also like