SlideShare a Scribd company logo
1 of 8
Download to read offline
PRAKTEK PEMROGRAMAN JARINGAN KOMPUTER
PROGRAM INFO SERVER DAN INFO CLIENT DENGAN
MENGGUNAKAN BAHASA PEMROGRAMAN JAVA
Oleh :
Nama : Tri Lestari
NIM : 061130701310
Kelas : 6 CD
JURUSAN TEKNIK KOMPUTER
POLITEKNIK NEGERI SRIWIJAYA
PALEMBANG
2014
PROGRAM INFO SERVER DAN INFO CLIENT DENGAN
MENGGUNAKAN BAHASA PEMROGRAMAN JAVA
Listing Program Info Server dan Info Client
A. Program Info Server
Nama Program infoserver.java
import java.io.*;
import java.net.*;
import java.util.*;
public class infoserver{
private final int INFO_PORT=50000;
private String datafromClient;
public infoserver() {
BufferedReader inFromClient;
DataOutputStream outToClient;
Socket serverSocket;
try {
ServerSocket infoserver =
new ServerSocket(INFO_PORT);
System.out.println("Server siap...");
while (true){
serverSocket = infoserver.accept();
System.out.println("Ada client" +
"yang terkoneksi!");
inFromClient =
new BufferedReader(
new InputStreamReader(
serverSocket.getInputStream()));
outToClient =
new DataOutputStream(
serverSocket.getOutputStream());
outToClient.writeBytes("InfoServer versi 0.1n"+
"hanya untuk testing..n"+
"Silahkan berikan perintah TIME|NET|QUITn");
boolean isQUIT = false;
while (!isQUIT) {
datafromClient = inFromClient.readLine();
if (datafromClient.startsWith("TIME")){
outToClient.writeBytes(new
Date().toString() + "n");
} else if (datafromClient.startsWith("NET")){
outToClient.writeBytes(
InetAddress.getByName("localhost").toString()+
"n");
} else if (datafromClient.startsWith("QUIT"))
{
isQUIT = true;
}
}
outToClient.close();
inFromClient.close();
serverSocket.close();
System.out.println("Koneksi client sudah
tertutup..");
}
}
catch (IOException ioe) {
System.out.print("error:" + ioe);
}
catch (Exception e) {
System.out.print("error:" + e);
}
}
public static void main(String[]args) {
new infoserver();
}
}
Setelah di compile, maka hasil tampilan programnya dapat dilihat
seperti dibawah ini:
B. Program Info Client
Nama Program infoclient.java
import java.net.*;
import java.io.*;
import java.util.*;
public class InfoClient {
private final int INFO_PORT=50000;
private final String TargetHost = "localhost";
private final String QUIT = "QUIT";
public InfoClient() {
try {
BufferedReader inFromUser =
new BufferedReader(new
InputStreamReader(System.in));
Socket clientSocket = new
Socket(TargetHost, INFO_PORT);
DataOutputStream outToServer =
new DataOutputStream(
clientSocket.getOutputStream());
BufferedReader inFromServer =
new BufferedReader(
new InputStreamReader(
clientSocket.getInputStream()));
System.out.println(inFromServer.readLine());
System.out.println(inFromServer.readLine());
System.out.println(inFromServer.readLine());
System.out.println("");
boolean isQuit = false;
while (!isQuit) {
System.out.print("Ketikkan Perintah Anda : ");
String cmd = inFromUser.readLine();
cmd = cmd.toUpperCase();
if (cmd.equals(QUIT)) {
isQuit = true;
}
outToServer.writeBytes(cmd + "n");
String result = inFromServer.readLine();
System.out.println("Dari Server: " + result);
}
outToServer.close();
inFromServer.close();
clientSocket.close();
}
catch (IOException ioe) {
System.out.println("Error:" + ioe);
}
catch (Exception e) {
System.out.println("Error:" + e);
}
}
public static void main(String[]args) {
new InfoClient();
}
}
Setelah di compile, maka hasil tampilan programnya dapat dilihat
seperti dibawah ini:
Ketika client telah terkoneksi dengan server, maka tampilan pada
jendela server akan seperti dibawah ini:
Pada jendela client, masukkan perintah yang diingin. Misalnya,
untuk melihat waktu dan jaringan yang terdapat pda PC atau Laptop.

More Related Content

Similar to Laporan info server dan info client

Networks lab
Networks labNetworks lab
Networks lab
svijiiii
 
Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
randymartin91030
 
networks-lab-excercise3.pdf
networks-lab-excercise3.pdfnetworks-lab-excercise3.pdf
networks-lab-excercise3.pdf
Jayaprasanna4
 
Integrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight ApplicationsIntegrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight Applications
Dan Wahlin
 
Write a java program to create a program that outputs to the command l.docx
Write a java program to create a program that outputs to the command l.docxWrite a java program to create a program that outputs to the command l.docx
Write a java program to create a program that outputs to the command l.docx
lez31palka
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
Qiangning Hong
 

Similar to Laporan info server dan info client (20)

Networks lab
Networks labNetworks lab
Networks lab
 
Networks lab
Networks labNetworks lab
Networks lab
 
IBM Monitoring and Diagnostics Tools - Health Center 3.0.2
IBM Monitoring and Diagnostics Tools - Health Center 3.0.2IBM Monitoring and Diagnostics Tools - Health Center 3.0.2
IBM Monitoring and Diagnostics Tools - Health Center 3.0.2
 
Socket Programming - nitish nagar
Socket Programming - nitish nagarSocket Programming - nitish nagar
Socket Programming - nitish nagar
 
Java RMI
Java RMIJava RMI
Java RMI
 
Sockets
SocketsSockets
Sockets
 
Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
 
networks-lab-excercise3.pdf
networks-lab-excercise3.pdfnetworks-lab-excercise3.pdf
networks-lab-excercise3.pdf
 
Networking Core Concept
Networking Core ConceptNetworking Core Concept
Networking Core Concept
 
Java 1
Java 1Java 1
Java 1
 
Securing your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris KelloggSecuring your Pulsar Cluster with Vault_Chris Kellogg
Securing your Pulsar Cluster with Vault_Chris Kellogg
 
Multiuser chat application using java
Multiuser chat application using javaMultiuser chat application using java
Multiuser chat application using java
 
Integrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight ApplicationsIntegrating Security Roles into Microsoft Silverlight Applications
Integrating Security Roles into Microsoft Silverlight Applications
 
Write a java program to create a program that outputs to the command l.docx
Write a java program to create a program that outputs to the command l.docxWrite a java program to create a program that outputs to the command l.docx
Write a java program to create a program that outputs to the command l.docx
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA) 11.Open Data Protocol(ODATA)
11.Open Data Protocol(ODATA)
 
Laporan tugas network programming
Laporan tugas network programmingLaporan tugas network programming
Laporan tugas network programming
 
#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIs#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIs
 

More from trilestari08

Laporan Chatting Server dan Client
Laporan Chatting Server dan ClientLaporan Chatting Server dan Client
Laporan Chatting Server dan Client
trilestari08
 
Laporan Info Server dan Info Client
Laporan Info Server dan Info ClientLaporan Info Server dan Info Client
Laporan Info Server dan Info Client
trilestari08
 
Laporan ambil nama
Laporan ambil namaLaporan ambil nama
Laporan ambil nama
trilestari08
 
Laporan Server dan Client
Laporan Server dan ClientLaporan Server dan Client
Laporan Server dan Client
trilestari08
 
Laporan server dan client
Laporan server dan clientLaporan server dan client
Laporan server dan client
trilestari08
 

More from trilestari08 (8)

Laporan get nama
Laporan get namaLaporan get nama
Laporan get nama
 
Laporan get ip
Laporan get ipLaporan get ip
Laporan get ip
 
Laporan Chatting Server dan Client
Laporan Chatting Server dan ClientLaporan Chatting Server dan Client
Laporan Chatting Server dan Client
 
Laporan Info Server dan Info Client
Laporan Info Server dan Info ClientLaporan Info Server dan Info Client
Laporan Info Server dan Info Client
 
Laporan ambil nama
Laporan ambil namaLaporan ambil nama
Laporan ambil nama
 
Laporan Ambil IP
Laporan Ambil IPLaporan Ambil IP
Laporan Ambil IP
 
Laporan Server dan Client
Laporan Server dan ClientLaporan Server dan Client
Laporan Server dan Client
 
Laporan server dan client
Laporan server dan clientLaporan server dan client
Laporan server dan client
 

Recently uploaded

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdfAzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
 
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAMWSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

Laporan info server dan info client

  • 1. PRAKTEK PEMROGRAMAN JARINGAN KOMPUTER PROGRAM INFO SERVER DAN INFO CLIENT DENGAN MENGGUNAKAN BAHASA PEMROGRAMAN JAVA Oleh : Nama : Tri Lestari NIM : 061130701310 Kelas : 6 CD JURUSAN TEKNIK KOMPUTER POLITEKNIK NEGERI SRIWIJAYA PALEMBANG 2014
  • 2. PROGRAM INFO SERVER DAN INFO CLIENT DENGAN MENGGUNAKAN BAHASA PEMROGRAMAN JAVA Listing Program Info Server dan Info Client A. Program Info Server Nama Program infoserver.java import java.io.*; import java.net.*; import java.util.*; public class infoserver{ private final int INFO_PORT=50000; private String datafromClient; public infoserver() { BufferedReader inFromClient; DataOutputStream outToClient; Socket serverSocket; try { ServerSocket infoserver = new ServerSocket(INFO_PORT); System.out.println("Server siap..."); while (true){ serverSocket = infoserver.accept(); System.out.println("Ada client" +
  • 3. "yang terkoneksi!"); inFromClient = new BufferedReader( new InputStreamReader( serverSocket.getInputStream())); outToClient = new DataOutputStream( serverSocket.getOutputStream()); outToClient.writeBytes("InfoServer versi 0.1n"+ "hanya untuk testing..n"+ "Silahkan berikan perintah TIME|NET|QUITn"); boolean isQUIT = false; while (!isQUIT) { datafromClient = inFromClient.readLine(); if (datafromClient.startsWith("TIME")){ outToClient.writeBytes(new Date().toString() + "n"); } else if (datafromClient.startsWith("NET")){ outToClient.writeBytes( InetAddress.getByName("localhost").toString()+ "n"); } else if (datafromClient.startsWith("QUIT")) { isQUIT = true; } } outToClient.close(); inFromClient.close(); serverSocket.close();
  • 4. System.out.println("Koneksi client sudah tertutup.."); } } catch (IOException ioe) { System.out.print("error:" + ioe); } catch (Exception e) { System.out.print("error:" + e); } } public static void main(String[]args) { new infoserver(); } } Setelah di compile, maka hasil tampilan programnya dapat dilihat seperti dibawah ini:
  • 5. B. Program Info Client Nama Program infoclient.java import java.net.*; import java.io.*; import java.util.*; public class InfoClient { private final int INFO_PORT=50000; private final String TargetHost = "localhost"; private final String QUIT = "QUIT"; public InfoClient() { try { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket(TargetHost, INFO_PORT); DataOutputStream outToServer = new DataOutputStream( clientSocket.getOutputStream()); BufferedReader inFromServer = new BufferedReader( new InputStreamReader( clientSocket.getInputStream())); System.out.println(inFromServer.readLine());
  • 6. System.out.println(inFromServer.readLine()); System.out.println(inFromServer.readLine()); System.out.println(""); boolean isQuit = false; while (!isQuit) { System.out.print("Ketikkan Perintah Anda : "); String cmd = inFromUser.readLine(); cmd = cmd.toUpperCase(); if (cmd.equals(QUIT)) { isQuit = true; } outToServer.writeBytes(cmd + "n"); String result = inFromServer.readLine(); System.out.println("Dari Server: " + result); } outToServer.close(); inFromServer.close(); clientSocket.close(); } catch (IOException ioe) { System.out.println("Error:" + ioe); } catch (Exception e) { System.out.println("Error:" + e); } } public static void main(String[]args) {
  • 7. new InfoClient(); } } Setelah di compile, maka hasil tampilan programnya dapat dilihat seperti dibawah ini: Ketika client telah terkoneksi dengan server, maka tampilan pada jendela server akan seperti dibawah ini:
  • 8. Pada jendela client, masukkan perintah yang diingin. Misalnya, untuk melihat waktu dan jaringan yang terdapat pda PC atau Laptop.