Tuesday, 21 April 2020

Tech Reporter

Creating a Chat Server Using Java






Introduction: Creating a Chat Server Using Java

Creating a Chat Server Using Java
Creating a Chat Server Using Java
Introduction
Networking is a major branch of programming that is vital to connecting users through devices. As such many programming languages have multiple ways to form connections users and servers or between peers. For starting out programming, Java is one of the first languages many programmers learn, and one of the interesting ways java can handle network connections is through the use of Java Sockets. I have prepared this tutorial to instruct how to use sockets in java by developing a chat server between one server and many users. This tutorial is divided between client side and server side development.
Requirements:
  • Java JDK (I used version 1.8.0_74 for this)
  • Java IDE (I used Eclipse Mars for this)
  • A package structure with the above classes
Timer: About 15-30 minutes
Skill: This guide assumes that you have basic Java experience and are familiar with common Java I/O types

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Setup a ServerSocket in the Server Class

Setup a ServerSocket in the Server Class
Create a static Server socket at the beginning of main in the ChatServer class and instantiate it with a port number.
TIP: ServerSockets may be instantiated with a port number other than 4444, but numbers lower than 1000 are more likely to already be in use by the system.

Step 2: Create a Socket in the Login Class

Create a Socket in the Login Class
Create a socket in the main method of Login, specifying the host address and port number. Since this is a login window, the socket can be an instance variable as it will be passed to the actual chat window later.
TIP: "localhost" is used in the socket parameters for debugging purposes to specify that the server is running on the same computer as the client. Later this can be changed to take a host address to connect to a remote server.

Step 3: Create a Loop to Continuously Accept Clients

Create a Loop to Continuously Accept Clients
Create a Loop to Continuously Accept Clients
After instantiating the serverSocket in chatServer, start a while loop that continuously accepts all clients.

Step 4: Create the Client Threads

Create the Client Threads
Create the Client Threads
  1. With the socket received from serversocket.accept, create a new ClientThread .
  2. Create a new Thread using the ClientThread, and then call start on the thread.
  3. In ClientThread, make ClientThread extend ChatServer, and implement Runnable
  4. Create the ClientThread constructor and add the method run.

Step 5: Create the Server Thread

Create the Server Thread
Create the Server Thread
  1. Create a new ServerThread using socket.
  2. Create a new Thread using the ServerThread, and then call start on the thread.
  3. In ServerThread, make ServerThread implement Runnable
  4. Create the ServerThread constructor and add the method run.

Step 6: Make the Client Thread Send and Receive Data

Make the Client Thread Send and Receive Data
Make the Client Thread Send and Receive Data
  1. In ClientThread make a private BufferedReader in to receive data from clients, and a PrintWriter to write to the client.
  2. Create a getter for the PrintWriter
  3. Initialize the PrintWriter in run with the socket's output stream, and the BufferedReader with a new InputStreamReader using the socket's input stream
  4. Create a while loop in run that checks for any new input and prints the input to all clients using the list of ClientThreads and the getter for the PrintWriter

Step 7: Make the Server Thread Send and Receive Data

Make the Server Thread Send and Receive Data
Make the Server Thread Send and Receive Data
Make the Server Thread Send and Receive Data
  1. In ServerThread make a private BufferedReader in to receive data from the server, another BufferedReader to receive data from the user, and a PrintWriter to write to the server.
  2. Initialize the PrintWriter in run with the socket's output stream, the server's BufferedReader with a new InputStreamReader using the socket's input stream, and the user's BufferedReader with a new InputStreamReader using System.In
  3. Create a while loop in run that checks for any new input from the server and prints the input to the console, and checks for any new input from the user and prints that input to the server.

Step 8: Test the Server and Add Optional Functionality

After running the server and launching clients, the program should relay all messages from each client to all other clients. This was a small test of what can be done with java sockets.
You can expand on this project by adding functionality to let the server itself relay messages, archiving messages, allowing other forms of input and more to become more familiar with java sockets and networking in general.
Read More
Tech Reporter

HTML code for Drop down

The select element

The select element is used to create a drop-down list:



Code

<!DOCTYPE html>
<html>
<body>

<h1>The select element</h1>

<p>The select element is used to create a drop-down list:</p>

<label for="cars">Choose a car:</label>

<select id="cars">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
 
</body>
</html>

Read More
Tech Reporter

Lenovo k4 note lock screen themes

Read More
Tech Reporter

True caller Installation and issues


True caller is widely user for knowing the caller id of the unknown numbers.

To install True caller click on Download : Download

True call caller ID issue





Truecaller name change






Read More
Tech Reporter

Delete mobile number from Truecaller

How To Remove Your Contact Details from TrueCaller:
Two ways are there to remove your number visible to others in truecaller search, one method is from TrueCaller App and another one is by TrueCaller Website.
Step 1: Navigate to the trueCaller Unlisting page in the browser.
Step 2: In this Unlisting Page, you will have a text box to enter your phone number which you want to unlist from truecaller search.
Step 3: Now, Enter the phone number with the country code in the Phone Number text box.
Step 4: Once Verified, the UNLIST PHONE NUMBER button will be enabled. Click on the button, a confirmation window will be shown. Confirm by clicking the UNLIST PHONE NUMBER in the confirmation window.
Step 5: Now, Your Phone Number was unlisted from truecaller search. A Confirmation Message will be shown as below. Please note that it will take up to 24 hours before the number gets removed.
Once you did the above steps, you can no longer use the app on your smartphone with that number.
Read More
Tech Reporter

Airtel free balacne due to COVID-19





Telecom major Bharti Airtel has announced some measures to help low-income group customers impacted by the COVID-19 crisis. Airtel has extended the prepaid packs validity till April 17. Subscribers will continue to get incoming calls on their Airtel mobile numbers even after the validity of their plan is exhausted. Airtel claims it will help over 80 million low-income mobile subscribers.

Airtel will also credit an additional Rs 10 of talk time in the pre-paid accounts of all these 80 million customers to enable them to make calls or send SMS. The offer has been kicked off, and these benefits will be available to users in the next 48 hours.

“These 80 million customers effectively cover all under-privileged households on the Airtel Network. These special measures will particularly benefit migrant workers and daily wage earners who may have been impacted due to the nationwide lockdown to combat COVID-19. All other customers on Airtel’s network are already recharging their accounts using online platforms,” said the company in a release.


“In this difficult hour of fighting off the threat of Covid-19, Airtel is committed to ensuring that all people remain connected without any disruptions. And for this objective, it is critical to take care of the under-privileged daily wage earners of our country, whose lives have been disrupted due to the lock-down,” said Shashwat Sharma, chief marketing officer, Bharti Airtel.


Meanwhile, Airtel has announced free access to its e-book platform Juggernaut Books to support people in staying home during the lockdown. "As India stays at home to support the government's efforts to contain the spread of Covid-19, readers can now access thousands of top books and novels on Juggernaut Books (formerly known as Airtel Books) for free by simply downloading the app (Android/iOS) on their smartphones," Bharti Airtel said in a statement.
Read More
Tech Reporter

Telugu movies Whatsapp status Video Songs

తెలుగు వీడియో సాంగ్స్ మరియు స్టేటస్ కొరకు 

మీరు కొన్ని యాప్స్ ఇన్స్టాల్ చేసికో వచ్చు 


హలో అప్ (Hello app)

టిక్ టాక్ (Tik tok)

యూ సి  వీడియో (UC video)

Read More

Featured post

Creating a Chat Server Using Java

Download Favorite Introduction: Creating a Chat Server Using Java Introduction Networking is a major bran...