Python Microproject
Python Microproject
A MICRO-PROJECT REPORT ON
(2023-24)
UNDER THE GUIDANCE OF
MR.V.M.KHARMATE
SUBMITTED BY
(“PWP”)
Yours Sincerely,
1. Pawar Yogesh Sanjay
2.Rathod Sachin Dnyaneshwar.
3.Satpute Amarnath Purushottam.
INDEX
1. Introduction.
2. Code
I. MultiThreadedServer .java
II. MultiThreadedClient1.java
III. MultiThreadedClient2.java
3. Output
4. Conclusion
5. Reference
INTRODUCTION
Multi-Client Chat Server using Sockets and Threads in Java
In this project, we will learn to create a Client-Server console application in Java. The project
will help us to understand the low-level network communication, and also a low-level
understanding of how popular chat applications like messenger and WhatsApp are built.
In the Client-Server model, the Server has a unique IP Address and port number. The client
tries to make a connection with the server using this port number and IP address. The server
listens and accepts the connection. Once the connection is built, the Server can receive a
message from the client as well as respond back a message to the client.
Since the project involves multiple clients that can send messages to each other, we will use
threads. The thread ensures that every client gets their own server socket.
For the Server application, we use the ServerSocket Class that binds to a specific port number.
We then create a server socket and listen for a connection with the Client and accept it. The
thread MultiThreadedServer is instantiated and started.
For the Client, we use the Socket class and initiate the connection to a server bypassing the IP
address and port number. We use the Scanner to get the input from the user and send the data to
the server.
We have used MultiThreadedClient1 class and MultiThreadedClient2 class to listen to the
response from the server, without getting blocked while reading from a Scanner. We have used
input BufferReader to get information from the client.
CODE
import random
# Validate guess
def check_guess(guess, secret_number):
if guess == secret_number:
return "Correct"
elif guess < secret_number:
return "Too low"
else:
return "Too high"
if result == "Correct":
print(f"Congratulations! You guessed the secret number {secret_number}
in {attempts} attempts.")
won = True
break
else:
print(f"{result}. Try again!")
if not won:
print(f"Sorry, you ran out of attempts! The secret number is
{secret_number}.")
if __name__ == "__main__":
print("Welcome to the Number Guessing Game!")
play_game()
output:
Advance Java 4th Unit
https://youtu.be/kqBmsLvWU14?si=MjvV0xCX_OApTrF1
https://gyawaliamit.medium.com/multi-client-chat-server-using-sockets-and-
threads-in-java-2d0b64cad4a7
CONCLUSION
Java Socket Programming provides a simple yet powerful way to enable communication
between multiple devices over a network. The use of multi-threading ensures that our chat
application can handle multiple clients simultaneously without freezing. Socket programming
has revolutionized the development of chat applications by providing an efficient, real-time
communication mechanism. This paper has provided an introduction to developing chat
applications using Socket programming, covering the underlying concepts, architecture, benefits,
practical implementation, future directions and challenge.