SlideShare a Scribd company logo
1 of 3
I need an explaining for each step in this code and the reason of it.
import java.io.*;
import java.net.*;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class TCPServer {
/**
* args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int port = 6000;
try (ServerSocket serverSocket = new ServerSocket(port)) {
System.out.println("Server is listening on port " + port);
while (true) {
System.out.println("waiting for a client to connect.");
Socket socket = serverSocket.accept();
System.out.println("New client connected");
DataInputStream dis = new DataInputStream(socket.getInputStream());
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
int option;
String text;
System.out.println("Waiting for mode.");
option=dis.readInt();
switch(option)
{
case 1:
System.out.println("open mode activated.");
dos.writeUTF("open mode activated.");
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
dos.writeUTF(text);
}while(!text.equals("exit"));
break;
case 2:
System.out.println("secure mode activated.");
dos.writeUTF("secure mode activated.");
String keyString="1234567890123456";
String ivString="6543210987654321";
IvParameterSpec iv=new IvParameterSpec(ivString.getBytes("UTF-8"));
SecretKeySpec key=new SecretKeySpec(keyString.getBytes("UTF-8"),"AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, key, iv);
String plainString="";
do
{
text=dis.readUTF();
System.out.println("client sent: " + text);
byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(text));
plainString=new String(plainText);
System.out.println("plain text is: " + plainString);
dos.writeUTF(text);
}while(!plainString.equals("exit"));
break;
case 3:
socket.close();
System.out.println("client has disconnected");
break;
}
}
} catch (Exception ex) {
/*System.out.println("Server exception: " + ex.getMessage());
ex.printStackTrace();
*/
System.out.println("port : " + port);
}
}
}
I need an explaining for each step in this code and the reason of it-.docx

More Related Content

Similar to I need an explaining for each step in this code and the reason of it-.docx

Networks lab
Networks labNetworks lab
Networks labsvijiiii
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopyayaria
 
TCP IP
TCP IPTCP IP
TCP IPhivasu
 
Sockets in nach0s
Sockets in nach0sSockets in nach0s
Sockets in nach0snaniix21_3
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Mumbai B.Sc.IT Study
 
Laporan multi client
Laporan multi clientLaporan multi client
Laporan multi clientichsanbarokah
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.comphanleson
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authenticationWindowsPhoneRocks
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programmingashok hirpara
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
Client server part 12
Client server part 12Client server part 12
Client server part 12fadlihulopi
 

Similar to I need an explaining for each step in this code and the reason of it-.docx (20)

Networks lab
Networks labNetworks lab
Networks lab
 
Chatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptopChatting dengan beberapa pc laptop
Chatting dengan beberapa pc laptop
 
Ipc
IpcIpc
Ipc
 
TCP IP
TCP IPTCP IP
TCP IP
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
 
Sockets in nach0s
Sockets in nach0sSockets in nach0s
Sockets in nach0s
 
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
 
Laporan multi client
Laporan multi clientLaporan multi client
Laporan multi client
 
分散式系統
分散式系統分散式系統
分散式系統
 
Winform
WinformWinform
Winform
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.com
 
Ppt of socket
Ppt of socketPpt of socket
Ppt of socket
 
Networking Core Concept
Networking Core ConceptNetworking Core Concept
Networking Core Concept
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
 
Java 1
Java 1Java 1
Java 1
 
Advance Java-Network Programming
Advance Java-Network ProgrammingAdvance Java-Network Programming
Advance Java-Network Programming
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Client server part 12
Client server part 12Client server part 12
Client server part 12
 
A.java
A.javaA.java
A.java
 

More from hendriciraida

In a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxIn a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxhendriciraida
 
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxIn a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxhendriciraida
 
In a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxIn a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxhendriciraida
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxhendriciraida
 
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxIn 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxhendriciraida
 
In 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxIn 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxhendriciraida
 
In 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxIn 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxhendriciraida
 
Important- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxImportant- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxhendriciraida
 
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docximport java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docxhendriciraida
 
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxImpact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxhendriciraida
 
Immune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxImmune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxhendriciraida
 
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxImani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxhendriciraida
 
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxIloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxhendriciraida
 
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxhendriciraida
 
If you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxIf you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxhendriciraida
 
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxIf the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxhendriciraida
 
If the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxIf the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxhendriciraida
 
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxIf NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxhendriciraida
 
If Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxIf Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxhendriciraida
 
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxIf a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxhendriciraida
 

More from hendriciraida (20)

In a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxIn a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docx
 
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxIn a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
 
In a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxIn a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docx
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
 
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxIn 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
 
In 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxIn 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docx
 
In 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxIn 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docx
 
Important- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxImportant- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docx
 
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docximport java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
 
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxImpact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
 
Immune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxImmune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docx
 
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxImani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
 
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxIloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
 
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
 
If you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxIf you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docx
 
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxIf the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
 
If the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxIf the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docx
 
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxIf NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
 
If Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxIf Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docx
 
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxIf a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

I need an explaining for each step in this code and the reason of it-.docx

  • 1. I need an explaining for each step in this code and the reason of it. import java.io.*; import java.net.*; import java.util.Base64; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; public class TCPServer { /** * args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int port = 6000; try (ServerSocket serverSocket = new ServerSocket(port)) { System.out.println("Server is listening on port " + port); while (true) { System.out.println("waiting for a client to connect."); Socket socket = serverSocket.accept(); System.out.println("New client connected"); DataInputStream dis = new DataInputStream(socket.getInputStream()); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); int option; String text; System.out.println("Waiting for mode."); option=dis.readInt(); switch(option) { case 1: System.out.println("open mode activated."); dos.writeUTF("open mode activated."); do { text=dis.readUTF(); System.out.println("client sent: " + text); dos.writeUTF(text);
  • 2. }while(!text.equals("exit")); break; case 2: System.out.println("secure mode activated."); dos.writeUTF("secure mode activated."); String keyString="1234567890123456"; String ivString="6543210987654321"; IvParameterSpec iv=new IvParameterSpec(ivString.getBytes("UTF-8")); SecretKeySpec key=new SecretKeySpec(keyString.getBytes("UTF-8"),"AES"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING"); cipher.init(Cipher.DECRYPT_MODE, key, iv); String plainString=""; do { text=dis.readUTF(); System.out.println("client sent: " + text); byte[] plainText = cipher.doFinal(Base64.getDecoder().decode(text)); plainString=new String(plainText); System.out.println("plain text is: " + plainString); dos.writeUTF(text); }while(!plainString.equals("exit")); break; case 3: socket.close(); System.out.println("client has disconnected"); break; } } } catch (Exception ex) { /*System.out.println("Server exception: " + ex.getMessage()); ex.printStackTrace(); */ System.out.println("port : " + port); } } }