Practical JavaScript Programming - Session 3/8Wilson Su
油
JavaScript is one of the most popular skills in todays job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
Practical JavaScript Programming does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. Youll learn about topics like Data Types, Functions, Events, AJAX and more.
Melihat Nama PC Menggunakan Aplikasi Pemograman Javayoyomay93
油
Aplikasi Java sederhana untuk mengambil nama komputer menggunakan kode InetAddress.getLocalHost() dan host.getHostName(). Program disimpan dengan nama "AmbilNama.java" dan dieksekusi untuk menampilkan nama komputer.
Mengambil IP Pada PC Menggunakan Bahasa Pemrograman Javayoyomay93
油
Program Java untuk mengambil alamat IP dan nama host lokal pada komputer menggunakan perintah InetAddress.getByName() dan mencetak hasilnya menggunakan println().
The document describes a program for creating a multi-client chatting application using Java Swing. It involves creating a chat server class with methods for accepting client connections, handling message passing between clients, and maintaining a list of connected clients. It also involves creating a chat client class with methods for connecting to the server, sending and receiving messages, and displaying messages and a list of connected clients. The program listing includes the code for the ChatServer and ChatClient classes to implement the client-server architecture for a graphical multi-user chat application.
Practical JavaScript Programming - Session 3/8Wilson Su
油
JavaScript is one of the most popular skills in todays job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
Practical JavaScript Programming does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. Youll learn about topics like Data Types, Functions, Events, AJAX and more.
Melihat Nama PC Menggunakan Aplikasi Pemograman Javayoyomay93
油
Aplikasi Java sederhana untuk mengambil nama komputer menggunakan kode InetAddress.getLocalHost() dan host.getHostName(). Program disimpan dengan nama "AmbilNama.java" dan dieksekusi untuk menampilkan nama komputer.
Mengambil IP Pada PC Menggunakan Bahasa Pemrograman Javayoyomay93
油
Program Java untuk mengambil alamat IP dan nama host lokal pada komputer menggunakan perintah InetAddress.getByName() dan mencetak hasilnya menggunakan println().
The document describes a program for creating a multi-client chatting application using Java Swing. It involves creating a chat server class with methods for accepting client connections, handling message passing between clients, and maintaining a list of connected clients. It also involves creating a chat client class with methods for connecting to the server, sending and receiving messages, and displaying messages and a list of connected clients. The program listing includes the code for the ChatServer and ChatClient classes to implement the client-server architecture for a graphical multi-user chat application.
1. Info Server dan Info Client Menggunakan
Bahasa Pemrograman Java
Oleh :
Yohana Damayanti
(061130701312)
6CD
JURUSAN TEKNIK KOMPUTER
POLITEKNIK NEGERI SRIWIJAYA
PALEMBANG
2. Pada bagian kali ini, Program yang dibuat, guna untuk mengetahui info
server dan info client suatu komputer. Berikut adalah listing codenya dan eksekusi
dari program yang telah dibuat.
A) 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"+
3. "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();
}
}
4. Jalankan program yang telah dibuat. Dengan cara klik ctrl+1 lalu ctrl+2,
maka tampilan server akan seperti berikut:
B) 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());
6. new InfoClient();
}
}
Kemudian running juga program InfoClient.java dengan cara klik ctrl+1 lalu
ctrl+2, maka tampilan akan seperti berikut:
Lihat ke bagian jendela server. Ketika Client telah terkoneksi dengan server,
maka tampilan akan seperti berikut:
Lalu kembali ke jendela Client untuk memilih perintah. Masukkan perintah
yang anda ingin, seperti ini untuk melihat waktu, dan jaringan yang terdapat di
PC/Laptop anda.