SlideShare a Scribd company logo
TCP/IP Client Server program example
Here is a simple example of client-server operation using two simple Java programs. There are
two programs, Server.java and Client.java.
The server returns the input message with all lowercase letters converted to uppercase.
These programs are missing some instructions.
The server program:
// import packages
classTCPServer {
publicstaticvoidmain(String argv[]) throwsException {
String clientSentence;
String capitalizedSentence;
//create Socket
..
while (true) {
//Connection
BufferedReaderinFromClient =
newBufferedReader(newInputStreamReader(connectionSocket.getInputStream()));
DataOutputStreamoutToClient = newDataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine(); //read what the client sent
System.out.println("Received: " + clientSentence);
capitalizedSentence = clientSentence.toUpperCase() + 'n';
outToClient.(capitalizedSentence); //writing to client
}
}
}
The client program
// Import packages
classTCPClient {
publicstaticvoidmain(String argv[]) throws Exception {
String sentence;
String modifiedSentence;
BufferedReaderinFromUser = newBufferedReader(newInputStreamReader(System.in));
//Connection
.
//Writing in the socket
.
BufferedReaderinFromServer =
newBufferedReader(newInputStreamReader(clientSocket.getInputStream()));
System.out.print("Enter a sentence: ");
sentence = inFromUser.readLine(); //reads a sentancefrom the user
.//send to server
modifiedSentence = inFromServer.readLine(); //recievefrom server
System.out.println("FROM SERVER: " + modifiedSentence);
//Close the socket
.
}
}

More Related Content

Similar to TCPIP Client Server program exampleHere is a simple example of .pdf

Kamaelia Protocol Walkthrough
Kamaelia Protocol WalkthroughKamaelia Protocol Walkthrough
Kamaelia Protocol Walkthrough
kamaelian
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
JAXLondon_Conference
 
Networks lab
Networks labNetworks lab
Networks lab
svijiiii
 
Networks lab
Networks labNetworks lab
Networks lab
svijiiii
 
network programing lab file ,
network programing lab file ,network programing lab file ,
network programing lab file ,
AAlha PaiKra
 
Call Back
Call BackCall Back
Call Back
leminhvuong
 
Call Back
Call BackCall Back
Call Back
phanleson
 
Call Back
Call BackCall Back
Call Back
leminhvuong
 
Call Back
Call BackCall Back
Call Back
leminhvuong
 
Module 1 Introduction
Module 1   IntroductionModule 1   Introduction
Module 1 Introduction
leminhvuong
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
Nitish Nagar
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
WSO2
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
secunderbadtirumalgi
 
assigemt calculater.docx
assigemt calculater.docxassigemt calculater.docx
assigemt calculater.docx
zekfeker
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
elliando dias
 
Networking & Socket Programming In Java
Networking & Socket Programming In JavaNetworking & Socket Programming In Java
Networking & Socket Programming In Java
Ankur Agrawal
 
17-Networking.pdf
17-Networking.pdf17-Networking.pdf
17-Networking.pdf
sophia763824
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
aaronmorton
 

Similar to TCPIP Client Server program exampleHere is a simple example of .pdf (20)

Kamaelia Protocol Walkthrough
Kamaelia Protocol WalkthroughKamaelia Protocol Walkthrough
Kamaelia Protocol Walkthrough
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Networks lab
Networks labNetworks lab
Networks lab
 
Networks lab
Networks labNetworks lab
Networks lab
 
network programing lab file ,
network programing lab file ,network programing lab file ,
network programing lab file ,
 
Call Back
Call BackCall Back
Call Back
 
Call Back
Call BackCall Back
Call Back
 
Call Back
Call BackCall Back
Call Back
 
Call Back
Call BackCall Back
Call Back
 
Module 1 Introduction
Module 1   IntroductionModule 1   Introduction
Module 1 Introduction
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
assigemt calculater.docx
assigemt calculater.docxassigemt calculater.docx
assigemt calculater.docx
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
Networking & Socket Programming In Java
Networking & Socket Programming In JavaNetworking & Socket Programming In Java
Networking & Socket Programming In Java
 
17-Networking.pdf
17-Networking.pdf17-Networking.pdf
17-Networking.pdf
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
 

More from allisontraders

Suppose you are designing a randomized intervention trial of a socia.pdf
Suppose you are designing a randomized intervention trial of a socia.pdfSuppose you are designing a randomized intervention trial of a socia.pdf
Suppose you are designing a randomized intervention trial of a socia.pdf
allisontraders
 
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdfSuppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
allisontraders
 
Suppose the U.S. president wants to estimate the proportion of the p.pdf
Suppose the U.S. president wants to estimate the proportion of the p.pdfSuppose the U.S. president wants to estimate the proportion of the p.pdf
Suppose the U.S. president wants to estimate the proportion of the p.pdf
allisontraders
 
Suppose we have a database for an university.The requirements are .pdf
Suppose we have a database for an university.The requirements are .pdfSuppose we have a database for an university.The requirements are .pdf
Suppose we have a database for an university.The requirements are .pdf
allisontraders
 
Suppose we have a database for an university. The requirements are a.pdf
Suppose we have a database for an university. The requirements are a.pdfSuppose we have a database for an university. The requirements are a.pdf
Suppose we have a database for an university. The requirements are a.pdf
allisontraders
 
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdf
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdfTanni Tamaki and Gerald Malada are a married couple and they equally.pdf
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdf
allisontraders
 
Technology is in many ways an enabler in shaping and defining our li.pdf
Technology is in many ways an enabler in shaping and defining our li.pdfTechnology is in many ways an enabler in shaping and defining our li.pdf
Technology is in many ways an enabler in shaping and defining our li.pdf
allisontraders
 
Ted talk To overcome challenges, stop comparing yourself to others .pdf
Ted talk To overcome challenges, stop comparing yourself to others .pdfTed talk To overcome challenges, stop comparing yourself to others .pdf
Ted talk To overcome challenges, stop comparing yourself to others .pdf
allisontraders
 
Teamwork that you have accomplished so far; What you have learned fr.pdf
Teamwork that you have accomplished so far; What you have learned fr.pdfTeamwork that you have accomplished so far; What you have learned fr.pdf
Teamwork that you have accomplished so far; What you have learned fr.pdf
allisontraders
 
Task II Read the following case stud thoroughly, then answer the fo.pdf
Task II Read the following case stud thoroughly, then answer the fo.pdfTask II Read the following case stud thoroughly, then answer the fo.pdf
Task II Read the following case stud thoroughly, then answer the fo.pdf
allisontraders
 
Task required to perform You will develop a Social Media Marketing .pdf
Task required to perform You will develop a Social Media Marketing .pdfTask required to perform You will develop a Social Media Marketing .pdf
Task required to perform You will develop a Social Media Marketing .pdf
allisontraders
 
TASK The Financial Controller is not attending the next Board meeti.pdf
TASK The Financial Controller is not attending the next Board meeti.pdfTASK The Financial Controller is not attending the next Board meeti.pdf
TASK The Financial Controller is not attending the next Board meeti.pdf
allisontraders
 
Task 1This program sorts an array of EMPLOYEE structures usin.pdf
Task 1This program sorts an array of EMPLOYEE structures usin.pdfTask 1This program sorts an array of EMPLOYEE structures usin.pdf
Task 1This program sorts an array of EMPLOYEE structures usin.pdf
allisontraders
 
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdfTalias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
allisontraders
 
Suppose that you wanted to create a crop plant that has cabbage leav.pdf
Suppose that you wanted to create a crop plant that has cabbage leav.pdfSuppose that you wanted to create a crop plant that has cabbage leav.pdf
Suppose that you wanted to create a crop plant that has cabbage leav.pdf
allisontraders
 
Take any successful, high performing organization.Elaborate the vi.pdf
Take any successful, high performing organization.Elaborate the vi.pdfTake any successful, high performing organization.Elaborate the vi.pdf
Take any successful, high performing organization.Elaborate the vi.pdf
allisontraders
 
Talaromyces marneffei1. What is its genus species and phyla2. I.pdf
Talaromyces marneffei1. What is its genus species and phyla2. I.pdfTalaromyces marneffei1. What is its genus species and phyla2. I.pdf
Talaromyces marneffei1. What is its genus species and phyla2. I.pdf
allisontraders
 
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdfTabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
allisontraders
 
T-tests are hypothesis tests for mean differences. They are used to .pdf
T-tests are hypothesis tests for mean differences. They are used to .pdfT-tests are hypothesis tests for mean differences. They are used to .pdf
T-tests are hypothesis tests for mean differences. They are used to .pdf
allisontraders
 
t=SMMM.pdf
t=SMMM.pdft=SMMM.pdf
t=SMMM.pdf
allisontraders
 

More from allisontraders (20)

Suppose you are designing a randomized intervention trial of a socia.pdf
Suppose you are designing a randomized intervention trial of a socia.pdfSuppose you are designing a randomized intervention trial of a socia.pdf
Suppose you are designing a randomized intervention trial of a socia.pdf
 
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdfSuppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
Suppose the nominal interest rate for both 2020 and 2021 is zero and.pdf
 
Suppose the U.S. president wants to estimate the proportion of the p.pdf
Suppose the U.S. president wants to estimate the proportion of the p.pdfSuppose the U.S. president wants to estimate the proportion of the p.pdf
Suppose the U.S. president wants to estimate the proportion of the p.pdf
 
Suppose we have a database for an university.The requirements are .pdf
Suppose we have a database for an university.The requirements are .pdfSuppose we have a database for an university.The requirements are .pdf
Suppose we have a database for an university.The requirements are .pdf
 
Suppose we have a database for an university. The requirements are a.pdf
Suppose we have a database for an university. The requirements are a.pdfSuppose we have a database for an university. The requirements are a.pdf
Suppose we have a database for an university. The requirements are a.pdf
 
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdf
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdfTanni Tamaki and Gerald Malada are a married couple and they equally.pdf
Tanni Tamaki and Gerald Malada are a married couple and they equally.pdf
 
Technology is in many ways an enabler in shaping and defining our li.pdf
Technology is in many ways an enabler in shaping and defining our li.pdfTechnology is in many ways an enabler in shaping and defining our li.pdf
Technology is in many ways an enabler in shaping and defining our li.pdf
 
Ted talk To overcome challenges, stop comparing yourself to others .pdf
Ted talk To overcome challenges, stop comparing yourself to others .pdfTed talk To overcome challenges, stop comparing yourself to others .pdf
Ted talk To overcome challenges, stop comparing yourself to others .pdf
 
Teamwork that you have accomplished so far; What you have learned fr.pdf
Teamwork that you have accomplished so far; What you have learned fr.pdfTeamwork that you have accomplished so far; What you have learned fr.pdf
Teamwork that you have accomplished so far; What you have learned fr.pdf
 
Task II Read the following case stud thoroughly, then answer the fo.pdf
Task II Read the following case stud thoroughly, then answer the fo.pdfTask II Read the following case stud thoroughly, then answer the fo.pdf
Task II Read the following case stud thoroughly, then answer the fo.pdf
 
Task required to perform You will develop a Social Media Marketing .pdf
Task required to perform You will develop a Social Media Marketing .pdfTask required to perform You will develop a Social Media Marketing .pdf
Task required to perform You will develop a Social Media Marketing .pdf
 
TASK The Financial Controller is not attending the next Board meeti.pdf
TASK The Financial Controller is not attending the next Board meeti.pdfTASK The Financial Controller is not attending the next Board meeti.pdf
TASK The Financial Controller is not attending the next Board meeti.pdf
 
Task 1This program sorts an array of EMPLOYEE structures usin.pdf
Task 1This program sorts an array of EMPLOYEE structures usin.pdfTask 1This program sorts an array of EMPLOYEE structures usin.pdf
Task 1This program sorts an array of EMPLOYEE structures usin.pdf
 
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdfTalias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
Talias Tea Shoppes ha llegado a un acuerdo con Consumer Rail Corp. .pdf
 
Suppose that you wanted to create a crop plant that has cabbage leav.pdf
Suppose that you wanted to create a crop plant that has cabbage leav.pdfSuppose that you wanted to create a crop plant that has cabbage leav.pdf
Suppose that you wanted to create a crop plant that has cabbage leav.pdf
 
Take any successful, high performing organization.Elaborate the vi.pdf
Take any successful, high performing organization.Elaborate the vi.pdfTake any successful, high performing organization.Elaborate the vi.pdf
Take any successful, high performing organization.Elaborate the vi.pdf
 
Talaromyces marneffei1. What is its genus species and phyla2. I.pdf
Talaromyces marneffei1. What is its genus species and phyla2. I.pdfTalaromyces marneffei1. What is its genus species and phyla2. I.pdf
Talaromyces marneffei1. What is its genus species and phyla2. I.pdf
 
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdfTabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
Tabla 7.14 Cincuenta a�os de supervivencia para hombres despu�s de .pdf
 
T-tests are hypothesis tests for mean differences. They are used to .pdf
T-tests are hypothesis tests for mean differences. They are used to .pdfT-tests are hypothesis tests for mean differences. They are used to .pdf
T-tests are hypothesis tests for mean differences. They are used to .pdf
 
t=SMMM.pdf
t=SMMM.pdft=SMMM.pdf
t=SMMM.pdf
 

Recently uploaded

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

TCPIP Client Server program exampleHere is a simple example of .pdf

  • 1. TCP/IP Client Server program example Here is a simple example of client-server operation using two simple Java programs. There are two programs, Server.java and Client.java. The server returns the input message with all lowercase letters converted to uppercase. These programs are missing some instructions. The server program: // import packages classTCPServer { publicstaticvoidmain(String argv[]) throwsException { String clientSentence; String capitalizedSentence; //create Socket .. while (true) { //Connection BufferedReaderinFromClient = newBufferedReader(newInputStreamReader(connectionSocket.getInputStream())); DataOutputStreamoutToClient = newDataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); //read what the client sent System.out.println("Received: " + clientSentence); capitalizedSentence = clientSentence.toUpperCase() + 'n'; outToClient.(capitalizedSentence); //writing to client
  • 2. } } } The client program // Import packages classTCPClient { publicstaticvoidmain(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReaderinFromUser = newBufferedReader(newInputStreamReader(System.in)); //Connection . //Writing in the socket . BufferedReaderinFromServer = newBufferedReader(newInputStreamReader(clientSocket.getInputStream())); System.out.print("Enter a sentence: "); sentence = inFromUser.readLine(); //reads a sentancefrom the user .//send to server modifiedSentence = inFromServer.readLine(); //recievefrom server System.out.println("FROM SERVER: " + modifiedSentence); //Close the socket . }
  • 3. }