1. Trang chủ
  2. » Luận Văn - Báo Cáo

Implement and demo for socket in ipc python program demonstrates a client server interaction using sockets

32 1 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Implement And Demo Socket In IPC Python Program Demonstrates A Client-Server Interaction Using Sockets
Tác giả Tran Thanh Tung, Nguyễn Minh Tú, Lé Anh Tuan, Lê Nguyễn Anh Tuấn
Người hướng dẫn TS. Hoàng Hữu Đức
Trường học Vietnam-Korea University of Information and Communication Technology
Chuyên ngành Computer Science
Thể loại Report
Năm xuất bản 2023
Thành phố Da Nang
Định dạng
Số trang 32
Dung lượng 1,87 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

SYSTEM PROGRAMMING REPORT IMPLEMENT AND DEMO FOR SOCKET IN IPC- PYTHON PROGRAM DEMONSTRATES A CLIENT-SERVER INTERACTION USING SOCKETS Lê Nguyễn Anh Tuấn 21IT457 Da Nang, October 22, 20

Trang 1

SYSTEM PROGRAMMING REPORT

IMPLEMENT AND DEMO FOR SOCKET IN IPC- PYTHON PROGRAM DEMONSTRATES A CLIENT-SERVER INTERACTION USING SOCKETS

Lê Nguyễn Anh Tuấn 21IT457

Da Nang, October 22, 2023

Trang 2

VIETNAM-KOREA UNIVERSITY OF INFORMATION AND

COMMUNICATION TECHNOLOGY

Department of Computer Science

VKU

SYSTEM PROGRAMMING REPORT

IMPLEMENT AND DEMO FOR SOCKET IN IPC- PYTHON PROGRAM DEMONSTRATES A CLIENT-SERVER INTERACTION USING SOCKETS

Lê Nguyễn Anh Tuấn 21IT457

Da Nang, October 22, 2023

Trang 3

GROUP TASK ASSIGNMENT TABLE

October 22, 2023 Instructor guides

TS Hoàng Hữu Đức

Trang 4

THANK YOU

We would not have been able to complete this report without your dedicated guidance and advice Dr Hoang Huu Duc | sincerely thank you for your guidance

1 would like to sincerely thank the teachers at the Vietnam-Korea University of

Information and Communications Technology, Da Nang University for

enthusiastically teaching, imparting valuable knowledge and creating conditions for

me to carry out the project This

We sincerely thank you as well as our predecessors for your help in the process

of making the report

Despite our best efforts, the report certainly has many shortcomings | look

forward to receiving the understanding and dedicated advice from teachers and friends

Trang 5

TABLE OF CONTENTS

Overview

Objectives and scope of the report

The basic concepts

Report structure

Socket and network programming:

Network communication socket:

TCP and UDP protocols

Related Python libraries

General architectural model:

Client-Server model:

Basic features and functions:

Instructions for installing the programming environment on Linux Ubuntu:

Deploy applications on Linux

Configure and manage networks on Linux

Handle security issues

Main parts of the source code:

Analyze how sockets are used in the application

Error handling and exception handling

Results of deployment and testing

Comment on application performance and stability

Discuss the difficulties encountered and how to solve them

Trang 6

Instructions for using the chat application 25

Trang 7

CHAPTER 1 INTRODUCTION AND THEORETICAL

1 Development of chat applications:

Real-time chat applications are increasingly popular and important in our daily lives Understanding how to create and implement them helps

improve programming skills and will be valuable in many real-life projects

2 Deeper understanding of socket programming:

Sockets programming is an important skill in network application development By learning how to use sockets in Python, we have the opportunity to gain a deeper understanding of how networks and data transfer protocols work

3 Applicable on Linux Ubuntu platform:

Linux Ubuntu is a popular operating system widely used in developing

and deploying applications Understanding how to deploy a chat

application on Linux will help us master the skill of deployment on this

platform

4 Promote learning and research abilities:

Choosing this topic helps members improve their learning and research

abilities Researching and implementing a real-life application creates opportunities to learn and test what you have learned

We believe that researching and implementing this topic will bring

valuable knowledge and skills in the field of software and network development, while bringing practical benefits to the community and businesses

Trang 8

Objectives and scope of the report

Target:

This report aims to provide a detailed tutorial on how to create a real-time chat

application using Python through socket programming and deploy it on the Linux Ubuntu operating system Specifically, the report's objectives include:

1 firstPresenting basic knowledge of socket programming:

Helps readers understand how sockets work, data transfer protocols, and how to create and manage network connections using Python

2 Instructions for building a real-time chat application:

Provides specific steps to develop a simple chat application with the ability to send and receive real-time messages between computers

3 Instructions for deploying applications on Linux Ubuntu:

Instructions for installing programming environments, deploying applications on Linux, and managing aspects related to networking and security

Limit:

The scope of the report includes:

1 Socket programming and Python:

The report will focus on using Python for socket programming and creating real-time chat applications

2 Deployment on Linux Ubuntu:

Instructions for deploying a chat application on Linux Ubuntu

3 Basic setup for the application:

Instructions for creating a simple chat application that allows the exchange of messages between computers over the network

4 Does not include complex functions:

The report will not discuss extended functions such as encryption, user

authentication, or integrating multiple users at the same time

This report helps readers get an overview of how to develop and deploy

a real-time chat application using Python and socket programming on the Linux Ubuntu environment

Trang 9

The basic concepts

In the process of researching and developing real-time chat applications using socket programming, there are some basic concepts that you need to understand Here

are some important concepts:

1 Socket: Socket 1s an object in network programming that allows computers to transmit and recetve data over the network Socket can be a client socket (connects to the server) or a server socket (accepts connections from clients) This is an important concept in real-time chat application development

TCP (Transmission Control Protocol): TCP 1s one of the two main protocols in socket programming, providing a reliable connection and a lossless data sequence It ensures that data sent from one party will be received by the other

party correctly and in order

UDP (User Datagram Protocol): UDP 1s a second socket protocol, focused on sending data with no guarantees of accuracy or order UDP is suitable for applications that need high speed and can tolerate data loss

IP (Internet Protocol): IP is a protocol that manages network addresses and computer addresses on the network It allows sending and receiving data on the Internet

TCP/IP layer system: The TCP/IP layer system includes the Internet layer (IP) and the communication layer (TCP or UDP), used to transmit data over the network

Client-server model: The client-server model is a way of organizing network

applications, including a server and a client The server provides services or resources, while the client requests and uses them

Port: Port is a positive integer that represents a specific application on a computer When you transmit data over a network, the port specifies which application on the computer will process that data

Linux Ubuntu: Linux Ubuntu 1s an open source operating system based on the

applications on servers

Trang 10

Report structure

This report is divided into specific sections to provide step-by-step instructions for implementing the project Main sections include:

Chapter 1: Introduction and theoretical basis

Chapter 2: Design and deploy applications on Linux Ubuntu

Chapter 3: Demo and results

Chapter 4: Conclusion

Trang 11

Socket and network programming:

A socket is a network application programming interface used to transmit and receive data over the internet It helps connect two programs running on a network to transmit and receive data over the Internet Socket operates through TCP layers or application identifier TCP Layer, thereby transmitting data through binding to a port

Network communication socket:

A socket is an object in network programming that allows a computer to transmit and

receive data over a network A socket can be thought of as a virtual window through

the network, where data can go and come through it We will look at two important types of sockets: client sockets and server sockets

Socket Client: Is an object created to connect to a socket server It usually

represents the application or device sending a request to the server

Socket Server: Is an object that accepts connections from socket clients and often performs request processing Servers can provide services or resources to clients

TCP and UDP protocols

In socket programming, we often use two important protocols: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol)

TCP (Transmission Control Protocol): TCP is a protocol that ensures reliability and that data sequences are not lost It establishes a connection between two computers and ensures that data is sent and received correctly and in order UDP (User Datagram Protocol): UDP focuses on sending data without ensuring

accuracy or order It is suitable for applications that need high speed and can

tolerate data loss

Related Python libraries

Python provides a number of useful libraries and modules for working with sockets

and networks Important libraries include:

socket: Basic library for working with sockets in Python

select: Module allows monitoring multiple socket connections at once

threading: Module helps handle multiple socket connections simultaneously

struct: Module allows you to encode and decode data transmitted over the network

socketserver: Library that allows building socket servers more easily

Trang 12

CHAPTER 2 DESIGN AND DEPLOY APPLICATIONS ON LINUX

UBUNTU General architectural model:

Before we start coding, we need to define the architectural model of our real-time chat application The architectural model defines how the application's components interact with each other In the case of chat applications, the architectural model usually includes two important parts: server and client

Client-Server model:

The client-server architecture model is one of the most popular models in network

application development In the case of a real-time chat application, this model will have two main parts:

Server: The server 1s the main component of the model The server's job is to

communication between clients The server can also store user data and intermediate messages during the chat

Client: The client is the part of the application installed on the user's computer The client is responsible for connecting to the server, sending and receiving

messages, and displaying the user interface The client provides functions to

users, allowing them to participate in conversations

Basic features and functions:

The architectural model of the real-time chat application includes the following

features and functionalities:

Connection: The client establishes a connection to the server using sockets This connection allows data transfer between the client and the server

Real-time chat: Clients and servers send and receive messages in real-time over

a socket connection The messages are displayed in the client's user interface User Interface: The client provides a graphical interface for users to enter and display messages The user interface may include a message input box, a chat box, and a list of users participating in the conversation

Trang 13

In the next sections of the report, we will delve into the implementation and programming of specific parts of this architectural model, ensuring the functionality and security of the chat application

Instructions for installing the programming environment on Linux Ubuntu: Setting up a programming environment on Linux can be quite diverse depending on the language and tools you want to use Below, I will guide you through installing a

basic programming environment on Linux using the Python language as an example

You can change the steps accordingly to the language or programming tool you want

to use

To install the Python programming environment on Linux, you can use the

following steps This tutorial is based on the Ubuntu operating system, but installing Python on other Linux distributions is similar Python can be installed through your system's package manager (e.g APT for Ubuntu)

Open Terminal: First, open terminal on Linux You can find the terminal in the application menu or use the key combination ‘Ctrl + Alt + T°

System updates: Before installing any software, update your system to ensure you are using the latest versions of software packages

Run the following commands:

sudo apt update sudo apt upgrade

Install Python: Python is one of the popular programming languages on Linux

Check if Python 1s pre-installed on the system by running the following command:

sudo apt install python3-pip

Trang 14

¢ Install a virtual environment (optional): To create a condensed development environment for Python projects, ‘virtualenv’ can be used Install ‘virtualenv’ with the following command:

sudo apt install python3-veny You can then create virtual environments for Python projects using the

following command:

python3 -m venv myenv

Where ‘myenv is the virtual environment name, you can leave the name as you

like

® Install a code editor: Depending on your preferences, you can use code editors like Visual Studio Code, Sublime Text, Atom or whatever code editor you want Install the code editor according to the instructions on the website of the code editor you choose

e Start programming: Now you have successfully installed Python on your Linux system and have a ready development environment You can start writing and executing Python code in the terminal or by selecting your editor or IDE

Deploy applications on Linux

Deploying an application on Linux requires a number of specific steps to ensure

that your application operates reliably on the target system Here 1s a detailed guide on how to deploy an application on Linux:

1 Prepare target system:

Make sure that the target system is properly installed and configured This includes choosing the right Linux operating system version for your application

2 Prepare resources:

Make sure you have prepared all the necessary resources for the application,

including source code, configuration files, documentation, and database data (if needed)

3 Install dependencies and libraries:

Install all the dependencies and libraries your application needs to function Use a package manager that the system supports, e.g APT for Ubuntu or YUM for CentOS

4 Application configuration:

Trang 15

Configure the application according to your specific requirements This includes editing configuration files, setting environment variables, and configuring database

connections (if applicable)

5 Deploy application source code:

Copy the application source code to the target system You can use SCP, SFTP or Git to do this

6 Launch the application:

Use the appropriate command to launch the application This can be a custom command or a command that executes your application's source code

7 Check the application:

Test the application to ensure that it works properly on the target system Use

logging tools to monitor and fix errors if necessary

8 Backup and version management:

Make sure you take regular backups of your application's source code and data

Use version control tools to track changes and maintain your application over time

Configure and manage networks on Linux

Network configuration and management on a Linux operating system is an

important part of managing your Linux computer or server Below are some basic concepts and commands so you can perform network configuration and management

on Linux

1 Understanding network protocols:

TCP/IP: This is the main network protocol used on most Linux systems It includes important parts such as IP address, subnet mask, gateway, and many other

concepts

2 Basic network management commands:

‘ifconfig’: This command allows you to view and configure information about

network interfaces on the system However, it has become obsolete and has been replaced by the ‘ip’ command in some new versions of Linux

‘ip’: This command is commonly used to configure and manage network interfaces, IP addresses, and many other options For example: ‘ip address show’, ‘ip link set’, “ip route add’

Trang 16

3 Configure static IP address:

To configure a static IP address for a network interface, you can use the ‘ip’ command or edit the */etc/network/interfaces’ configuration file

4 Network service management:

Use ‘systemd* to manage network services on most modern Linux versions Use commands like ‘systemctl start’, ‘systemctl stop’, ‘systemctl restart’ to manage network services such as NetworkManager or systemd-networkd

5 Install and configure Firewall:

Use iptables or firewalld to manage the firewall on your Linux system Configure rules to control network traffic

6 DNS management:

Edit the ‘/etc/resolv.conf file to set the default DNS server, or use NetworkManager to manage DNS settings

7 Configure bonding and VLAN (if needed):

If you need to create bonding or VLAN (Virtual LAN) to manage the network effectively, you can use a tool like ‘ifenslave’ or edit the configuration file

Handle security issues

1 Use AppArmor or SELinux:

AppArmor and SELinux are policy-based access control tools that allow you to

define and control access to your applications They help limit the chances of an application being hacked and accessing sensitive information

2 Firewall:

Use a firewall to control network traffic and prevent unauthorized access to the system iptables and ufw (Uncomplicated Firewall) are some popular firewall tools on Linux

Ngày đăng: 20/12/2024, 16:26

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w