SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
JAVA NETWORKING
Mobile Programming
NETWORKTODAY
NETWORKTODAY
NETWORKTODAY
NETWORKTODAY
NETWORK IS…
WEB IS BIGGER NETWORK
HOWTHEY COMMUNICATE?
PROTOCOL
ILLUSTRATION
IP: 192.168.1.1
IP: 192.168.1.2 IP: 192.168.1.3 IP: 192.168.1.4 IP: 192.168.1.5 IP: 192.168.1.6
DETAILED ILLUSTRATION
Logical Path
Physical Layer
Internet Layer (IP) Internet Layer (IP)
Transport Layer (TCP/IP) Transport Layer (TCP/IP)
Application Layer Application Layer
TERMINOLOGY
• Transmission Control Protocol
• User Datagram Protocol
• Port
• URL
• HTTP
MORETERMINOLOGY
• HTML
• XML
• FTP
• SMTP
• POP3/IMAP
PROTOCOL SCANNER
1 import java.net.*;
2
3 public class ProtocolTester {
4 public static void main(String[] args) {
5 String url = "www.bl.ac.id";
6
7 testProtocol("http://" + url);
8 testProtocol("https://" + url);
9 testProtocol("ftp://" + url);
10 testProtocol("nfs://" + url);
11 testProtocol("telnet://" + url);
12 testProtocol("mailto:rizafahmi@gmail.com");
13
14
15 }
16
17 private static void testProtocol (String url) {
18 try {
19 URL u = new URL(url);
20 System.out.println(u.getProtocol() + " is supported.");
21 } catch (MalformedURLException e) {
22 String protocol = url.substring(0, url.indexOf(":"));
23 System.out.println(protocol + " is not supported");
24 }
25 }
26 }
YOURTURN!
PORT SCANNER
1 import java.net.*;
2 import java.io.*;
3
4 public class LowPortScanner {
5 public static void main(String[] args) {
6 String host = "www.bl.ac.id";
7 System.out.println("Tunggu ya, sedang
mendeteksi...");
8
9 for (int i = 1; i < 100; i++) {
10 try {
11 Socket s = new Socket(host, i);
12 System.out.println("Port " + i + " digunakan
" + host);
13 } catch (UnknownHostException e) {
14 System.err.println(e);
15 } catch (IOException e) {
16 System.out.println("Port " + i + " Tidak
Digunakan " + host);
17 }
18 }
19 }
20 }
YOURTURN!
DOWNLOAD AND PARSE
HTML PAGE
1 import java.net.*;
2 import java.io.*;
3 public class SourceViewer {
4
5 public static void main (String[] args) {
6 if (args.length > 0) {
7 InputStream in = null;
8 try {
9 URL u = new URL(args[0]);
10 in = u.openStream();
11
12 in = new BufferedInputStream(in);
13 Reader r = new InputStreamReader(in);
14 int c;
15 while((c = r.read()) != -1) {
16 System.out.print((char) c);
17 }
18 } catch (MalformedURLException e) {
19 System.out.print(args[0] + " is not
parseable URL");
20 } catch (IOException e) {
21 System.err.println(e);
22 } finally {
23 if (in != null) {
24 try {
25 in.close();
26 } catch (IOException e) {
27 // ignore
28 }
29 }
30 }
31
32 }
33 }
34 }
> java SourceViewer http://www.bl.ac.id/
<!DOCTYPE html>
<html lang="id-ID">
<head>
<meta charset="UTF-8" />
<title>Universitas Budi Luhur</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="http://www.budiluhur.ac.id/xmlrpc.php" />
<script type="text/javascript" src="http://www.budiluhur.ac.id/wp-
content/themes/new-bl/images/jquery.js"></script>
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://
www.
budiluhur.ac.id/xmlrpc.php?rsd">
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://
www.
budiluhur.ac.id/wp-includes/wlwmanifest.xml">
<link rel="index" title="Universitas Budi Luhur" href="http://
www.budiluhur.ac.
id/">
<meta name="generator" content="WordPress 3.0.1">
…
YOURTURN!
SENDING EMAIL
1 import java.util.*;
2 import javax.mail.*;
3 import javax.mail.internet.*;
4 import javax.activation.*;
5
6 public class SendEmail {
7 public static void main (String[] args) {
8 String to = "rizafahmi@gmail.com";
9 String from = “riza@appsco.id";
10 String host = "192.168.1.134";
11 Properties properties = System.getProperties();
12 properties.setProperty("mail.smtp.host", host);
13 properties.put("mail.smtp.port", 1025);
14 Session session = Session.getDefaultInstance(properties);
15
16 try {
17 MimeMessage message = new MimeMessage(session);
18 message.setFrom(new InternetAddress(from));
19 message.addRecipient(Message.RecipientType.TO, new
InternetAddress(to));
20 message.setSubject("This is the subject line");
21 message.setText("This is actual message");
22
23 Transport.send(message);
24 System.out.println("Sent message successfully...");
25 } catch (MessagingException e) {
26 e.printStackTrace();
27 }
28 }
29 }
30
RECEIVING EMAIL
1 import java.util.Properties;
2 import javax.mail.*;
3 import javax.mail.internet.*;
4
5 public class POP3Client {
6 public static void main(String[] args) throws Exception {
7
8 Properties properties = getProperties();
9
10 Session session = getSession(properties);
11
12 Store store = connectingStore(session);
13
14 Folder inbox = getInboxFolder(store, "Inbox");
15
16 Message[] messages = inbox.getMessages();
17
18 if (messages.length == 0)
19 System.out.println("No message found");
20
21 System.out.println(messages.length);
22
23 inbox.close(true);
24 store.close();
25 }
26
27 private static Properties getProperties() {
28
29 Properties properties = System.getProperties();
30 properties.put("mail.pop3.port", 995);
31 properties.put("mail.pop3.ssl.enable", true);
32 properties.setProperty("mail.pop3.ssl.trust", "*");
33
34 return properties;
35 }
36
37 private static Session getSession(Properties properties) {
38 Session session = Session.getDefaultInstance(properties);
39
40 return session;
41 }
42
43 private static Store connectingStore(Session session) throws
Exception {
44 String host = "pop.zoho.com";
45 String username = "riza@appsco.id";
46 String password = "123456";
47
48 Store store = session.getStore("pop3");
49 store.connect(host, 995, username, password);
50
51 return store;
52 }
53
54 private static Folder getInboxFolder(Store store, String
folder) throws
55 Exception {
56 Folder inbox = store.getFolder("Inbox");
57 inbox.open(Folder.READ_ONLY);
58
59 return inbox;
60 }
61 }
YOURTURN!
LET’S DO CHAT!
PROTOCOL
1 import java.net.*;
2 import java.io.*;
3
4 public class KnockKnockProtocol {
5 private static final int WAITING = 0;
6 private static final int SENTKNOCKKNOCK = 1;
7 private static final int SENTCLUE = 2;
8 private static final int ANOTHER = 3;
9 private static final int NUMJOKES = 5;
10
11 private int state = WAITING;
12 private int currentJoke = 0;
13 private String[] clues = {"Bessarion", "Colby", "Gary", "Teodor", "Kamala"};
14 private String[] answers = {"Matiin AC dong, dingin nih!", "Lagi pusing
15 ya?", "Kelihatan ngga?", "Semoga sukses",
16 "Bazinga!"};
17
18 public String processInput(String inputString) {
19 String outputString = null;
20
21 if (state == WAITING) {
22 outputString = "Tok, tok, tok";
23 state = SENTKNOCKKNOCK;
24 } else if (state == SENTKNOCKKNOCK) {
25 if (inputString.equalsIgnoreCase("Siapa?")) {
26 outputString = clues[currentJoke];
27 state = SENTCLUE;
28 } else {
29 outputString = "Seharusnya kamu menjawab "Siapa?"! " + "Yuk kita
30 coba lagi. Tok, tok, tok";
31 state = ANOTHER;
32 }
33 } else if (state == SENTCLUE) {
34 if (inputString.equalsIgnoreCase(clues[currentJoke] + " siapa?")) {
35 outputString = answers[currentJoke] + " Ingin orang lain? (y/n)";
36 state = ANOTHER;
37 } else {
38 outputString = "Seharusnya "" + clues[currentJoke] + " siapa?"" +
39 "! Coba lagi yaa. Tok, tok, tok";
40 state = SENTKNOCKKNOCK;
41 }
42 } else if (state == ANOTHER) {
43 if (inputString.equalsIgnoreCase("y")) {
44 outputString = "Tok, tok, tok";
45 if (currentJoke == (NUMJOKES - 1))
46 currentJoke = 0;
47 else
48 currentJoke++;
49 state = SENTKNOCKKNOCK;
50 } else {
51 outputString = "Bye bye!";
52 state = WAITING;
53 }
54
55 }
56
57 return outputString;
58 }
59 }
SERVER
1 import java.net.*;
2 import java.io.*;
3
4 public class KnockKnockServer {
5 public static void main(String[] args) throws IOException {
6 ServerSocket serverSocket = null;
7
8 try {
9 serverSocket = new ServerSocket(4444);
10 System.out.println("Ok, server ready!");
11 } catch (IOException e) {
12 System.err.println("port 4444 tidak dapat digunakan.");
13 System.exit(1);
14 }
15
16 Socket clientSocket = null;
17 try {
18 clientSocket = serverSocket.accept();
19 } catch (IOException e) {
20 System.err.println("Client gagal menggunakan port.");
21 System.exit(1);
22 }
23
24 PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
25
26 BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.
27 getInputStream()));
28
29 String inputLine, outputLine;
30
31 KnockKnockProtocol kkp = new KnockKnockProtocol();
32 outputLine = kkp.processInput(null);
33 out.println(outputLine);
34
35 while((inputLine = in.readLine()) != null) {
36 outputLine = kkp.processInput(inputLine);
37 out.println(outputLine);
38
39 if (outputLine.equals("Bye bye!"))
40 break;
41 }
42
43 out.close();
44 in.close();
45 clientSocket.close();
46 serverSocket.close();
47 }
48 }
CLIENT
1 import java.io.*;
2 import java.net.*;
3
4 public class KnockKnockClient {
5 public static void main(String[] args) throws IOException {
6 Socket kkSocket = null;
7 PrintWriter out = null;
8 BufferedReader in = null;
9
10 try {
11 kkSocket = new Socket("localhost", 4444);
12 out = new PrintWriter(kkSocket.getOutputStream(), true);
13 in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())
14 );
15
16 } catch (UnknownHostException e) {
17 System.err.println("Host localhost tidak ditemukan.");
18 System.exit(1);
19 } catch (IOException e) {
20 System.err.println("Koneksi Input output ke localhost gagal.");
21 System.exit(1);
22 }
23
24 BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in)
25 );
26 String fromServer;
27 String fromUser;
28
29 while((fromServer = in.readLine()) != null) {
30 System.out.println("Server: " + fromServer);
31 if (fromServer.equals("Bye bye!"))
32 break;
33
34 fromUser = stdIn.readLine();
35
36 if (fromUser != null) {
37 System.out.println("Client: " + fromUser);
38 out.println(fromUser);
39 }
40 }
41
42 out.close();
43 in.close();
44 stdIn.close();
45 kkSocket.close();
46 }
47 }
YOURTURN!

Weitere ähnliche Inhalte

Was ist angesagt?

My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestratorYoungHeon (Roy) Kim
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷Chiwon Song
 
Owin e o Projeto Katana
Owin e o Projeto KatanaOwin e o Projeto Katana
Owin e o Projeto KatanaAndre Carlucci
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Antonios Giannopoulos
 
Inventory program in mca p1
Inventory program in mca p1Inventory program in mca p1
Inventory program in mca p1rameshvvv
 
Openstack Testbed_ovs_virtualbox_devstack_single node
Openstack Testbed_ovs_virtualbox_devstack_single nodeOpenstack Testbed_ovs_virtualbox_devstack_single node
Openstack Testbed_ovs_virtualbox_devstack_single nodeYongyoon Shin
 
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...PROIDEA
 
MySQL replication & cluster
MySQL replication & clusterMySQL replication & cluster
MySQL replication & clusterelliando dias
 
Hibernate Import.Sql I18n
Hibernate Import.Sql I18nHibernate Import.Sql I18n
Hibernate Import.Sql I18nyifi2009
 
Scalable Socket Server by Aryo
Scalable Socket Server by AryoScalable Socket Server by Aryo
Scalable Socket Server by AryoAgate Studio
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享Chia Wei Tsai
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonGeert Van Pamel
 
The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196Mahmoud Samir Fayed
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
Percona XtraDB 集群内部
Percona XtraDB 集群内部Percona XtraDB 集群内部
Percona XtraDB 集群内部YUCHENG HU
 

Was ist angesagt? (20)

My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷
 
Owin e o Projeto Katana
Owin e o Projeto KatanaOwin e o Projeto Katana
Owin e o Projeto Katana
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
 
Lab 1 my sql tutorial
Lab 1 my sql tutorial Lab 1 my sql tutorial
Lab 1 my sql tutorial
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
 
Inventory program in mca p1
Inventory program in mca p1Inventory program in mca p1
Inventory program in mca p1
 
Openstack Testbed_ovs_virtualbox_devstack_single node
Openstack Testbed_ovs_virtualbox_devstack_single nodeOpenstack Testbed_ovs_virtualbox_devstack_single node
Openstack Testbed_ovs_virtualbox_devstack_single node
 
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...
[CONFidence 2016]: Alex Plaskett, Georgi Geshev - QNX: 99 Problems but a Micr...
 
MySQL replication & cluster
MySQL replication & clusterMySQL replication & cluster
MySQL replication & cluster
 
Hibernate Import.Sql I18n
Hibernate Import.Sql I18nHibernate Import.Sql I18n
Hibernate Import.Sql I18n
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
Scalable Socket Server by Aryo
Scalable Socket Server by AryoScalable Socket Server by Aryo
Scalable Socket Server by Aryo
 
Squid file
Squid fileSquid file
Squid file
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
 
A little waf
A little wafA little waf
A little waf
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemon
 
The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196The Ring programming language version 1.7 book - Part 52 of 196
The Ring programming language version 1.7 book - Part 52 of 196
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
Percona XtraDB 集群内部
Percona XtraDB 集群内部Percona XtraDB 集群内部
Percona XtraDB 集群内部
 

Andere mochten auch

Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakBrief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakRiza Fahmi
 
Sony lazuardi native mobile app with javascript
Sony lazuardi   native mobile app with javascriptSony lazuardi   native mobile app with javascript
Sony lazuardi native mobile app with javascriptPHP Indonesia
 
APPSCoast Pitch Deck
APPSCoast Pitch DeckAPPSCoast Pitch Deck
APPSCoast Pitch DeckRiza Fahmi
 
Meteor Talk At TokoPedia
Meteor Talk At TokoPediaMeteor Talk At TokoPedia
Meteor Talk At TokoPediaRiza Fahmi
 
Muhammad azamuddin introduction-to-reactjs
Muhammad azamuddin   introduction-to-reactjsMuhammad azamuddin   introduction-to-reactjs
Muhammad azamuddin introduction-to-reactjsPHP Indonesia
 
React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016Simon Sturmer
 
Styling Your React App
Styling Your React AppStyling Your React App
Styling Your React AppRiza Fahmi
 
Fellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your SuperpowerFellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your SuperpowerRiza Fahmi
 
Serverless NodeJS With AWS Lambda
Serverless NodeJS With AWS LambdaServerless NodeJS With AWS Lambda
Serverless NodeJS With AWS LambdaRiza Fahmi
 
React Webinar With CodePolitan
React Webinar With CodePolitanReact Webinar With CodePolitan
React Webinar With CodePolitanRiza Fahmi
 
Team 101: How to Build The A Team For Your Startup
Team 101: How to Build The A Team For Your StartupTeam 101: How to Build The A Team For Your Startup
Team 101: How to Build The A Team For Your StartupRiza Fahmi
 

Andere mochten auch (12)

Brief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapakBrief Intro to Phoenix - Elixir Meetup at BukaLapak
Brief Intro to Phoenix - Elixir Meetup at BukaLapak
 
Sony lazuardi native mobile app with javascript
Sony lazuardi   native mobile app with javascriptSony lazuardi   native mobile app with javascript
Sony lazuardi native mobile app with javascript
 
APPSCoast Pitch Deck
APPSCoast Pitch DeckAPPSCoast Pitch Deck
APPSCoast Pitch Deck
 
Meteor Talk At TokoPedia
Meteor Talk At TokoPediaMeteor Talk At TokoPedia
Meteor Talk At TokoPedia
 
Muhammad azamuddin introduction-to-reactjs
Muhammad azamuddin   introduction-to-reactjsMuhammad azamuddin   introduction-to-reactjs
Muhammad azamuddin introduction-to-reactjs
 
React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016React Fundamentals - Jakarta JS, Apr 2016
React Fundamentals - Jakarta JS, Apr 2016
 
Styling Your React App
Styling Your React AppStyling Your React App
Styling Your React App
 
Fellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your SuperpowerFellow Developers, Let's Discover Your Superpower
Fellow Developers, Let's Discover Your Superpower
 
Serverless NodeJS With AWS Lambda
Serverless NodeJS With AWS LambdaServerless NodeJS With AWS Lambda
Serverless NodeJS With AWS Lambda
 
Basic Operating System
Basic Operating SystemBasic Operating System
Basic Operating System
 
React Webinar With CodePolitan
React Webinar With CodePolitanReact Webinar With CodePolitan
React Webinar With CodePolitan
 
Team 101: How to Build The A Team For Your Startup
Team 101: How to Build The A Team For Your StartupTeam 101: How to Build The A Team For Your Startup
Team 101: How to Build The A Team For Your Startup
 

Ähnlich wie Mobile Programming - Network Universitas Budi Luhur

201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaFrank Lyaruu
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
I need you to modify and change the loop in this code without changing.docx
I need you to modify and change the loop in this code without changing.docxI need you to modify and change the loop in this code without changing.docx
I need you to modify and change the loop in this code without changing.docxhendriciraida
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"epamspb
 
Laporan multiclient chatting client server
Laporan multiclient chatting client serverLaporan multiclient chatting client server
Laporan multiclient chatting client servertrilestari08
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
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
 
Testing in android
Testing in androidTesting in android
Testing in androidjtrindade
 
I need an explaining for each step in this code and the reason of it-.docx
I need an explaining for each step in this code and the reason of it-.docxI need an explaining for each step in this code and the reason of it-.docx
I need an explaining for each step in this code and the reason of it-.docxhendriciraida
 

Ähnlich wie Mobile Programming - Network Universitas Budi Luhur (20)

201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Server1
Server1Server1
Server1
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
I need you to modify and change the loop in this code without changing.docx
I need you to modify and change the loop in this code without changing.docxI need you to modify and change the loop in this code without changing.docx
I need you to modify and change the loop in this code without changing.docx
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Laporan multiclient chatting client server
Laporan multiclient chatting client serverLaporan multiclient chatting client server
Laporan multiclient chatting client server
 
Ipc
IpcIpc
Ipc
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
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...
 
Testing in android
Testing in androidTesting in android
Testing in android
 
Java
JavaJava
Java
 
I need an explaining for each step in this code and the reason of it-.docx
I need an explaining for each step in this code and the reason of it-.docxI need an explaining for each step in this code and the reason of it-.docx
I need an explaining for each step in this code and the reason of it-.docx
 
Nantes Jug - Java 7
Nantes Jug - Java 7Nantes Jug - Java 7
Nantes Jug - Java 7
 

Mehr von Riza Fahmi

Membangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan PhoenixMembangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan PhoenixRiza Fahmi
 
Berbagai Pilihan Karir Developer
Berbagai Pilihan Karir DeveloperBerbagai Pilihan Karir Developer
Berbagai Pilihan Karir DeveloperRiza Fahmi
 
Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020Riza Fahmi
 
Remote Working/Learning
Remote Working/LearningRemote Working/Learning
Remote Working/LearningRiza Fahmi
 
How to learn programming
How to learn programmingHow to learn programming
How to learn programmingRiza Fahmi
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRiza Fahmi
 
Menguak Misteri Module Bundler
Menguak Misteri Module BundlerMenguak Misteri Module Bundler
Menguak Misteri Module BundlerRiza Fahmi
 
Beberapa Web API Menarik
Beberapa Web API MenarikBeberapa Web API Menarik
Beberapa Web API MenarikRiza Fahmi
 
MVP development from software developer perspective
MVP development from software developer perspectiveMVP development from software developer perspective
MVP development from software developer perspectiveRiza Fahmi
 
Ekosistem JavaScript di Indonesia
Ekosistem JavaScript di IndonesiaEkosistem JavaScript di Indonesia
Ekosistem JavaScript di IndonesiaRiza Fahmi
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonMLRiza Fahmi
 
How I Generate Idea
How I Generate IdeaHow I Generate Idea
How I Generate IdeaRiza Fahmi
 
Strategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop SlideStrategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop SlideRiza Fahmi
 
Lesson Learned from Prolific Developers
Lesson Learned from Prolific DevelopersLesson Learned from Prolific Developers
Lesson Learned from Prolific DevelopersRiza Fahmi
 
Clean Code JavaScript
Clean Code JavaScriptClean Code JavaScript
Clean Code JavaScriptRiza Fahmi
 
The Future of AI
The Future of AIThe Future of AI
The Future of AIRiza Fahmi
 
Chrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take AwaysChrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take AwaysRiza Fahmi
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Riza Fahmi
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJSRiza Fahmi
 
Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonMLRiza Fahmi
 

Mehr von Riza Fahmi (20)

Membangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan PhoenixMembangun Aplikasi Web dengan Elixir dan Phoenix
Membangun Aplikasi Web dengan Elixir dan Phoenix
 
Berbagai Pilihan Karir Developer
Berbagai Pilihan Karir DeveloperBerbagai Pilihan Karir Developer
Berbagai Pilihan Karir Developer
 
Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020Web dan Progressive Web Apps di 2020
Web dan Progressive Web Apps di 2020
 
Remote Working/Learning
Remote Working/LearningRemote Working/Learning
Remote Working/Learning
 
How to learn programming
How to learn programmingHow to learn programming
How to learn programming
 
Rapid App Development with AWS Amplify
Rapid App Development with AWS AmplifyRapid App Development with AWS Amplify
Rapid App Development with AWS Amplify
 
Menguak Misteri Module Bundler
Menguak Misteri Module BundlerMenguak Misteri Module Bundler
Menguak Misteri Module Bundler
 
Beberapa Web API Menarik
Beberapa Web API MenarikBeberapa Web API Menarik
Beberapa Web API Menarik
 
MVP development from software developer perspective
MVP development from software developer perspectiveMVP development from software developer perspective
MVP development from software developer perspective
 
Ekosistem JavaScript di Indonesia
Ekosistem JavaScript di IndonesiaEkosistem JavaScript di Indonesia
Ekosistem JavaScript di Indonesia
 
Perkenalan ReasonML
Perkenalan ReasonMLPerkenalan ReasonML
Perkenalan ReasonML
 
How I Generate Idea
How I Generate IdeaHow I Generate Idea
How I Generate Idea
 
Strategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop SlideStrategi Presentasi Untuk Developer Workshop Slide
Strategi Presentasi Untuk Developer Workshop Slide
 
Lesson Learned from Prolific Developers
Lesson Learned from Prolific DevelopersLesson Learned from Prolific Developers
Lesson Learned from Prolific Developers
 
Clean Code JavaScript
Clean Code JavaScriptClean Code JavaScript
Clean Code JavaScript
 
The Future of AI
The Future of AIThe Future of AI
The Future of AI
 
Chrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take AwaysChrome Dev Summit 2018 - Personal Take Aways
Chrome Dev Summit 2018 - Personal Take Aways
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
 
Introduction to ReasonML
Introduction to ReasonMLIntroduction to ReasonML
Introduction to ReasonML
 

Kürzlich hochgeladen

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Kürzlich hochgeladen (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Mobile Programming - Network Universitas Budi Luhur

  • 7. WEB IS BIGGER NETWORK
  • 10. ILLUSTRATION IP: 192.168.1.1 IP: 192.168.1.2 IP: 192.168.1.3 IP: 192.168.1.4 IP: 192.168.1.5 IP: 192.168.1.6
  • 11. DETAILED ILLUSTRATION Logical Path Physical Layer Internet Layer (IP) Internet Layer (IP) Transport Layer (TCP/IP) Transport Layer (TCP/IP) Application Layer Application Layer
  • 12. TERMINOLOGY • Transmission Control Protocol • User Datagram Protocol • Port • URL • HTTP
  • 13. MORETERMINOLOGY • HTML • XML • FTP • SMTP • POP3/IMAP
  • 15. 1 import java.net.*; 2 3 public class ProtocolTester { 4 public static void main(String[] args) { 5 String url = "www.bl.ac.id"; 6 7 testProtocol("http://" + url); 8 testProtocol("https://" + url); 9 testProtocol("ftp://" + url); 10 testProtocol("nfs://" + url); 11 testProtocol("telnet://" + url); 12 testProtocol("mailto:rizafahmi@gmail.com"); 13 14 15 } 16 17 private static void testProtocol (String url) { 18 try { 19 URL u = new URL(url); 20 System.out.println(u.getProtocol() + " is supported."); 21 } catch (MalformedURLException e) { 22 String protocol = url.substring(0, url.indexOf(":")); 23 System.out.println(protocol + " is not supported"); 24 } 25 } 26 }
  • 18. 1 import java.net.*; 2 import java.io.*; 3 4 public class LowPortScanner { 5 public static void main(String[] args) { 6 String host = "www.bl.ac.id"; 7 System.out.println("Tunggu ya, sedang mendeteksi..."); 8 9 for (int i = 1; i < 100; i++) { 10 try { 11 Socket s = new Socket(host, i); 12 System.out.println("Port " + i + " digunakan " + host); 13 } catch (UnknownHostException e) { 14 System.err.println(e); 15 } catch (IOException e) { 16 System.out.println("Port " + i + " Tidak Digunakan " + host); 17 } 18 } 19 } 20 }
  • 21. 1 import java.net.*; 2 import java.io.*; 3 public class SourceViewer { 4 5 public static void main (String[] args) { 6 if (args.length > 0) { 7 InputStream in = null; 8 try { 9 URL u = new URL(args[0]); 10 in = u.openStream(); 11 12 in = new BufferedInputStream(in); 13 Reader r = new InputStreamReader(in); 14 int c; 15 while((c = r.read()) != -1) { 16 System.out.print((char) c); 17 }
  • 22. 18 } catch (MalformedURLException e) { 19 System.out.print(args[0] + " is not parseable URL"); 20 } catch (IOException e) { 21 System.err.println(e); 22 } finally { 23 if (in != null) { 24 try { 25 in.close(); 26 } catch (IOException e) { 27 // ignore 28 } 29 } 30 } 31 32 } 33 } 34 }
  • 23. > java SourceViewer http://www.bl.ac.id/ <!DOCTYPE html> <html lang="id-ID"> <head> <meta charset="UTF-8" /> <title>Universitas Budi Luhur</title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="pingback" href="http://www.budiluhur.ac.id/xmlrpc.php" /> <script type="text/javascript" src="http://www.budiluhur.ac.id/wp- content/themes/new-bl/images/jquery.js"></script> <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http:// www. budiluhur.ac.id/xmlrpc.php?rsd"> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http:// www. budiluhur.ac.id/wp-includes/wlwmanifest.xml"> <link rel="index" title="Universitas Budi Luhur" href="http:// www.budiluhur.ac. id/"> <meta name="generator" content="WordPress 3.0.1"> …
  • 26. 1 import java.util.*; 2 import javax.mail.*; 3 import javax.mail.internet.*; 4 import javax.activation.*; 5 6 public class SendEmail { 7 public static void main (String[] args) { 8 String to = "rizafahmi@gmail.com"; 9 String from = “riza@appsco.id"; 10 String host = "192.168.1.134"; 11 Properties properties = System.getProperties(); 12 properties.setProperty("mail.smtp.host", host); 13 properties.put("mail.smtp.port", 1025); 14 Session session = Session.getDefaultInstance(properties); 15
  • 27. 16 try { 17 MimeMessage message = new MimeMessage(session); 18 message.setFrom(new InternetAddress(from)); 19 message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); 20 message.setSubject("This is the subject line"); 21 message.setText("This is actual message"); 22 23 Transport.send(message); 24 System.out.println("Sent message successfully..."); 25 } catch (MessagingException e) { 26 e.printStackTrace(); 27 } 28 } 29 } 30
  • 29. 1 import java.util.Properties; 2 import javax.mail.*; 3 import javax.mail.internet.*; 4 5 public class POP3Client { 6 public static void main(String[] args) throws Exception { 7 8 Properties properties = getProperties(); 9 10 Session session = getSession(properties); 11 12 Store store = connectingStore(session); 13 14 Folder inbox = getInboxFolder(store, "Inbox"); 15 16 Message[] messages = inbox.getMessages(); 17 18 if (messages.length == 0) 19 System.out.println("No message found"); 20 21 System.out.println(messages.length); 22 23 inbox.close(true); 24 store.close(); 25 } 26
  • 30. 27 private static Properties getProperties() { 28 29 Properties properties = System.getProperties(); 30 properties.put("mail.pop3.port", 995); 31 properties.put("mail.pop3.ssl.enable", true); 32 properties.setProperty("mail.pop3.ssl.trust", "*"); 33 34 return properties; 35 } 36 37 private static Session getSession(Properties properties) { 38 Session session = Session.getDefaultInstance(properties); 39 40 return session; 41 } 42
  • 31. 43 private static Store connectingStore(Session session) throws Exception { 44 String host = "pop.zoho.com"; 45 String username = "riza@appsco.id"; 46 String password = "123456"; 47 48 Store store = session.getStore("pop3"); 49 store.connect(host, 995, username, password); 50 51 return store; 52 } 53 54 private static Folder getInboxFolder(Store store, String folder) throws 55 Exception { 56 Folder inbox = store.getFolder("Inbox"); 57 inbox.open(Folder.READ_ONLY); 58 59 return inbox; 60 } 61 }
  • 34.
  • 36. 1 import java.net.*; 2 import java.io.*; 3 4 public class KnockKnockProtocol { 5 private static final int WAITING = 0; 6 private static final int SENTKNOCKKNOCK = 1; 7 private static final int SENTCLUE = 2; 8 private static final int ANOTHER = 3; 9 private static final int NUMJOKES = 5; 10 11 private int state = WAITING; 12 private int currentJoke = 0; 13 private String[] clues = {"Bessarion", "Colby", "Gary", "Teodor", "Kamala"}; 14 private String[] answers = {"Matiin AC dong, dingin nih!", "Lagi pusing 15 ya?", "Kelihatan ngga?", "Semoga sukses", 16 "Bazinga!"}; 17
  • 37. 18 public String processInput(String inputString) { 19 String outputString = null; 20 21 if (state == WAITING) { 22 outputString = "Tok, tok, tok"; 23 state = SENTKNOCKKNOCK; 24 } else if (state == SENTKNOCKKNOCK) { 25 if (inputString.equalsIgnoreCase("Siapa?")) { 26 outputString = clues[currentJoke]; 27 state = SENTCLUE; 28 } else { 29 outputString = "Seharusnya kamu menjawab "Siapa?"! " + "Yuk kita 30 coba lagi. Tok, tok, tok"; 31 state = ANOTHER; 32 } 33 } else if (state == SENTCLUE) { 34 if (inputString.equalsIgnoreCase(clues[currentJoke] + " siapa?")) { 35 outputString = answers[currentJoke] + " Ingin orang lain? (y/n)"; 36 state = ANOTHER; 37 } else { 38 outputString = "Seharusnya "" + clues[currentJoke] + " siapa?"" + 39 "! Coba lagi yaa. Tok, tok, tok"; 40 state = SENTKNOCKKNOCK; 41 }
  • 38. 42 } else if (state == ANOTHER) { 43 if (inputString.equalsIgnoreCase("y")) { 44 outputString = "Tok, tok, tok"; 45 if (currentJoke == (NUMJOKES - 1)) 46 currentJoke = 0; 47 else 48 currentJoke++; 49 state = SENTKNOCKKNOCK; 50 } else { 51 outputString = "Bye bye!"; 52 state = WAITING; 53 } 54 55 } 56 57 return outputString; 58 } 59 }
  • 40. 1 import java.net.*; 2 import java.io.*; 3 4 public class KnockKnockServer { 5 public static void main(String[] args) throws IOException { 6 ServerSocket serverSocket = null; 7 8 try { 9 serverSocket = new ServerSocket(4444); 10 System.out.println("Ok, server ready!"); 11 } catch (IOException e) { 12 System.err.println("port 4444 tidak dapat digunakan."); 13 System.exit(1); 14 } 15 16 Socket clientSocket = null; 17 try { 18 clientSocket = serverSocket.accept(); 19 } catch (IOException e) { 20 System.err.println("Client gagal menggunakan port."); 21 System.exit(1); 22 } 23
  • 41. 24 PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); 25 26 BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket. 27 getInputStream())); 28 29 String inputLine, outputLine; 30 31 KnockKnockProtocol kkp = new KnockKnockProtocol(); 32 outputLine = kkp.processInput(null); 33 out.println(outputLine); 34 35 while((inputLine = in.readLine()) != null) { 36 outputLine = kkp.processInput(inputLine); 37 out.println(outputLine); 38 39 if (outputLine.equals("Bye bye!")) 40 break; 41 } 42 43 out.close(); 44 in.close(); 45 clientSocket.close(); 46 serverSocket.close(); 47 } 48 }
  • 43. 1 import java.io.*; 2 import java.net.*; 3 4 public class KnockKnockClient { 5 public static void main(String[] args) throws IOException { 6 Socket kkSocket = null; 7 PrintWriter out = null; 8 BufferedReader in = null; 9 10 try { 11 kkSocket = new Socket("localhost", 4444); 12 out = new PrintWriter(kkSocket.getOutputStream(), true); 13 in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()) 14 ); 15 16 } catch (UnknownHostException e) { 17 System.err.println("Host localhost tidak ditemukan."); 18 System.exit(1); 19 } catch (IOException e) { 20 System.err.println("Koneksi Input output ke localhost gagal."); 21 System.exit(1); 22 } 23
  • 44. 24 BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in) 25 ); 26 String fromServer; 27 String fromUser; 28 29 while((fromServer = in.readLine()) != null) { 30 System.out.println("Server: " + fromServer); 31 if (fromServer.equals("Bye bye!")) 32 break; 33 34 fromUser = stdIn.readLine(); 35 36 if (fromUser != null) { 37 System.out.println("Client: " + fromUser); 38 out.println(fromUser); 39 } 40 } 41 42 out.close(); 43 in.close(); 44 stdIn.close(); 45 kkSocket.close(); 46 } 47 }