SlideShare a Scribd company logo
1 of 19
Download to read offline
Introduction The Client The Server The Knock Knock Protocol References
THE KNOCK KNOCK PROTOCOL
Muhammad Adil Raja
Roaming Researchers, R .
cbna
December 2, 2015
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
OUTLINE
1 INTRODUCTION
2 THE CLIENT
3 THE SERVER
4 THE KNOCK KNOCK PROTOCOL
5 REFERENCES
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
OUTLINE
1 INTRODUCTION
2 THE CLIENT
3 THE SERVER
4 THE KNOCK KNOCK PROTOCOL
5 REFERENCES
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
OUTLINE
1 INTRODUCTION
2 THE CLIENT
3 THE SERVER
4 THE KNOCK KNOCK PROTOCOL
5 REFERENCES
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
OUTLINE
1 INTRODUCTION
2 THE CLIENT
3 THE SERVER
4 THE KNOCK KNOCK PROTOCOL
5 REFERENCES
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
OUTLINE
1 INTRODUCTION
2 THE CLIENT
3 THE SERVER
4 THE KNOCK KNOCK PROTOCOL
5 REFERENCES
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
INTRODUCTION
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE CLIENT I
/∗
∗ Copyright ( c ) 1995, 2013, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved .
∗
∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without
∗ modification , are permitted provided that the f o l l o w i n g conditions
∗ are met :
∗
∗ − Redistributions of source code must r e t a i n the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer .
∗
∗ − Redistributions in binary form must reproduce the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the
∗ documentation and / or other materials provided with the d i s t r i b u t i o n .
∗
∗ − Neither the name of Oracle or the names of i t s
∗ c o n t r i b u t o r s may be used to endorse or promote products derived
∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission .
∗
∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL ,
∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE CLIENT II
∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING
∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
∗/
import java . io . ∗ ;
import java . net . ∗ ;
public class KnockKnockClient {
public static void main ( String [ ] args ) throws IOException {
i f ( args . length != 2) {
System . err . p r i n t l n (
"Usage : java EchoClient <host name> <port number>" ) ;
System . e x i t ( 1 ) ;
}
String hostName = args [ 0 ] ;
int portNumber = Integer . parseInt ( args [ 1 ] ) ;
try (
Socket kkSocket = new Socket ( hostName , portNumber ) ;
P r i n t W r i t e r out = new P r i n t W r i t e r ( kkSocket . getOutputStream ( ) , true ) ;
BufferedReader in = new BufferedReader (
new InputStreamReader ( kkSocket . getInputStream ( ) ) ) ;
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE CLIENT III
) {
BufferedReader stdIn =
new BufferedReader (new InputStreamReader ( System . in ) ) ;
String fromServer ;
String fromUser ;
while ( ( fromServer = in . readLine ( ) ) != null ) {
System . out . p r i n t l n ( " Server : " + fromServer ) ;
i f ( fromServer . equals ( "Bye . " ) )
break ;
fromUser = stdIn . readLine ( ) ;
i f ( fromUser != null ) {
System . out . p r i n t l n ( " Client : " + fromUser ) ;
out . p r i n t l n ( fromUser ) ;
}
}
} catch ( UnknownHostException e ) {
System . err . p r i n t l n ( "Don ’ t know about host " + hostName ) ;
System . e x i t ( 1 ) ;
} catch ( IOException e ) {
System . err . p r i n t l n ( " Couldn ’ t get I /O f o r the connection to " +
hostName ) ;
System . e x i t ( 1 ) ;
}
}
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE CLIENT IV
}
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE SERVER I
/∗
∗ Copyright ( c ) 1995, 2014, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved .
∗
∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without
∗ modification , are permitted provided that the f o l l o w i n g conditions
∗ are met :
∗
∗ − Redistributions of source code must r e t a i n the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer .
∗
∗ − Redistributions in binary form must reproduce the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the
∗ documentation and / or other materials provided with the d i s t r i b u t i o n .
∗
∗ − Neither the name of Oracle or the names of i t s
∗ c o n t r i b u t o r s may be used to endorse or promote products derived
∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission .
∗
∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL ,
∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE SERVER II
∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING
∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
∗/
import java . net . ∗ ;
import java . io . ∗ ;
public class KnockKnockServer {
public static void main ( String [ ] args ) throws IOException {
i f ( args . length != 1) {
System . err . p r i n t l n ( "Usage : java KnockKnockServer <port number>" ) ;
System . e x i t ( 1 ) ;
}
int portNumber = Integer . parseInt ( args [ 0 ] ) ;
try (
ServerSocket serverSocket = new ServerSocket ( portNumber ) ;
Socket clientSocket = serverSocket . accept ( ) ;
P r i n t W r i t e r out =
new P r i n t W r i t e r ( clientSocket . getOutputStream ( ) , true ) ;
BufferedReader in = new BufferedReader (
new InputStreamReader ( clientSocket . getInputStream ( ) ) ) ;
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE SERVER III
) {
String inputLine , outputLine ;
/ / I n i t i a t e conversation with c l i e n t
KnockKnockProtocol kkp = new KnockKnockProtocol ( ) ;
outputLine = kkp . processInput ( null ) ;
out . p r i n t l n ( outputLine ) ;
while ( ( inputLine = in . readLine ( ) ) != null ) {
outputLine = kkp . processInput ( inputLine ) ;
out . p r i n t l n ( outputLine ) ;
i f ( outputLine . equals ( "Bye . " ) )
break ;
}
} catch ( IOException e ) {
System . out . p r i n t l n ( " Exception caught when t r y i n g to l i s t e n on port "
+ portNumber + " or l i s t e n i n g f o r a connection " ) ;
System . out . p r i n t l n ( e . getMessage ( ) ) ;
}
}
}
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE KNOCK KNOCK PROTOCOL I
/∗
∗ Copyright ( c ) 1995, 2008, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved .
∗
∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without
∗ modification , are permitted provided that the f o l l o w i n g conditions
∗ are met :
∗
∗ − Redistributions of source code must r e t a i n the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer .
∗
∗ − Redistributions in binary form must reproduce the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the
∗ documentation and / or other materials provided with the d i s t r i b u t i o n .
∗
∗ − Neither the name of Oracle or the names of i t s
∗ c o n t r i b u t o r s may be used to endorse or promote products derived
∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission .
∗
∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL ,
∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE KNOCK KNOCK PROTOCOL II
∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING
∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
∗/
import java . net . ∗ ;
import java . io . ∗ ;
public class KnockKnockProtocol {
private static f i n a l int WAITING = 0;
private static f i n a l int SENTKNOCKKNOCK = 1;
private static f i n a l int SENTCLUE = 2;
private static f i n a l int ANOTHER = 3;
private static f i n a l int NUMJOKES = 5;
private int state = WAITING ;
private int currentJoke = 0;
private String [ ] clues = { " Turnip " , " L i t t l e Old Lady " , " Atch " , "Who" , "Who" } ;
private String [ ] answers = { " Turnip the heat , i t ’ s cold in here ! " ,
" I didn ’ t know you could yodel ! " ,
" Bless you ! " ,
" Is there an owl in here?" ,
" Is there an echo in here?" } ;
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE KNOCK KNOCK PROTOCOL III
public String processInput ( String theInput ) {
String theOutput = null ;
i f ( state == WAITING) {
theOutput = " Knock ! Knock ! " ;
state = SENTKNOCKKNOCK;
} else i f ( state == SENTKNOCKKNOCK) {
i f ( theInput . equalsIgnoreCase ( "Who ’ s there?" ) ) {
theOutput = clues [ currentJoke ] ;
state = SENTCLUE;
} else {
theOutput = "You ’ re supposed to say  "Who ’ s there ?  " ! " +
" Try again . Knock ! Knock ! " ;
}
} else i f ( state == SENTCLUE) {
i f ( theInput . equalsIgnoreCase ( clues [ currentJoke ] + " who?" ) ) {
theOutput = answers [ currentJoke ] + " Want another? ( y / n ) " ;
state = ANOTHER;
} else {
theOutput = "You ’ re supposed to say  " " +
clues [ currentJoke ] +
" who?  " " +
" ! Try again . Knock ! Knock ! " ;
state = SENTKNOCKKNOCK;
}
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
THE KNOCK KNOCK PROTOCOL IV
} else i f ( state == ANOTHER) {
i f ( theInput . equalsIgnoreCase ( " y " ) ) {
theOutput = " Knock ! Knock ! " ;
i f ( currentJoke == (NUMJOKES − 1))
currentJoke = 0;
else
currentJoke ++;
state = SENTKNOCKKNOCK;
} else {
theOutput = "Bye . " ;
state = WAITING ;
}
}
return theOutput ;
}
}
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
Introduction The Client The Server The Knock Knock Protocol References
REFERENCES
The source code has been taken from
here.
This presentation has been produced with LATEX.
Berlin, beetle.
Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol

More Related Content

Similar to The Knock Knock Protocol

File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Socketsadil raja
 
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for Android
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for AndroidApp Optimizations Using Qualcomm Snapdragon LLVM Compiler for Android
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for AndroidQualcomm Developer Network
 
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...Satya Harish
 
Hack any website
Hack any websiteHack any website
Hack any websitesunil kumar
 
Automating the Elastic Stack
Automating the Elastic StackAutomating the Elastic Stack
Automating the Elastic StackElasticsearch
 
Third party attributions-click-to-call
Third party attributions-click-to-callThird party attributions-click-to-call
Third party attributions-click-to-callRositadianamanullang
 
Webinar: Extend The Power of The ForgeRock Identity Platform Through Scripting
Webinar: Extend The Power of The ForgeRock Identity Platform Through ScriptingWebinar: Extend The Power of The ForgeRock Identity Platform Through Scripting
Webinar: Extend The Power of The ForgeRock Identity Platform Through ScriptingForgeRock
 
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)Luca Bongiorni
 
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...Nagios
 
Leverage the Network
Leverage the NetworkLeverage the Network
Leverage the NetworkCisco Canada
 
Top Ten Tips for IBM i Security and Compliance
Top Ten Tips for IBM i Security and ComplianceTop Ten Tips for IBM i Security and Compliance
Top Ten Tips for IBM i Security and CompliancePrecisely
 
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...HostedbyConfluent
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rulesFreddy Buenaño
 

Similar to The Knock Knock Protocol (20)

File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for Android
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for AndroidApp Optimizations Using Qualcomm Snapdragon LLVM Compiler for Android
App Optimizations Using Qualcomm Snapdragon LLVM Compiler for Android
 
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...
HH QUALCOMM using qualcomm® snapdragon™ llvm compiler to optimize apps for 32...
 
Readme
ReadmeReadme
Readme
 
Signlic
SignlicSignlic
Signlic
 
cisco
cisco cisco
cisco
 
Acknow
AcknowAcknow
Acknow
 
Signlic
SignlicSignlic
Signlic
 
D3 Unix Hot Backup
D3 Unix Hot BackupD3 Unix Hot Backup
D3 Unix Hot Backup
 
Hack any website
Hack any websiteHack any website
Hack any website
 
Automating the Elastic Stack
Automating the Elastic StackAutomating the Elastic Stack
Automating the Elastic Stack
 
Third party attributions-click-to-call
Third party attributions-click-to-callThird party attributions-click-to-call
Third party attributions-click-to-call
 
Webinar: Extend The Power of The ForgeRock Identity Platform Through Scripting
Webinar: Extend The Power of The ForgeRock Identity Platform Through ScriptingWebinar: Extend The Power of The ForgeRock Identity Platform Through Scripting
Webinar: Extend The Power of The ForgeRock Identity Platform Through Scripting
 
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
Introduction to Mobile Application Security - Techcity 2015 (Vilnius)
 
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...
Nagios Conference 2013 - Fernando Hönig - Distributed Monitoring and Cloud Sc...
 
Leverage the Network
Leverage the NetworkLeverage the Network
Leverage the Network
 
Rm09a fin
Rm09a finRm09a fin
Rm09a fin
 
Top Ten Tips for IBM i Security and Compliance
Top Ten Tips for IBM i Security and ComplianceTop Ten Tips for IBM i Security and Compliance
Top Ten Tips for IBM i Security and Compliance
 
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...
Reigning in Protobuf with David Navalho and Graham Stirling | Kafka Summit Lo...
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 

More from adil raja

A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specificationadil raja
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehiclesadil raja
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystifiedadil raja
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)adil raja
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Researchadil raja
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistanadil raja
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousingadil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPadil raja
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specificationsadil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...adil raja
 
Modelling the Effect of Packet Loss on Speech Quality
Modelling the Effect of Packet Loss on Speech QualityModelling the Effect of Packet Loss on Speech Quality
Modelling the Effect of Packet Loss on Speech Qualityadil raja
 
A Random Presentation
A Random PresentationA Random Presentation
A Random Presentationadil raja
 

More from adil raja (20)

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Research
 
Thesis
ThesisThesis
Thesis
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistan
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
 
VoIP
VoIPVoIP
VoIP
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...
Modeling the Effect of packet Loss on Speech Quality: GP Based Symbolic Regre...
 
Modelling the Effect of Packet Loss on Speech Quality
Modelling the Effect of Packet Loss on Speech QualityModelling the Effect of Packet Loss on Speech Quality
Modelling the Effect of Packet Loss on Speech Quality
 
A Random Presentation
A Random PresentationA Random Presentation
A Random Presentation
 

Recently uploaded

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 

The Knock Knock Protocol

  • 1. Introduction The Client The Server The Knock Knock Protocol References THE KNOCK KNOCK PROTOCOL Muhammad Adil Raja Roaming Researchers, R . cbna December 2, 2015 Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 2. Introduction The Client The Server The Knock Knock Protocol References OUTLINE 1 INTRODUCTION 2 THE CLIENT 3 THE SERVER 4 THE KNOCK KNOCK PROTOCOL 5 REFERENCES Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 3. Introduction The Client The Server The Knock Knock Protocol References OUTLINE 1 INTRODUCTION 2 THE CLIENT 3 THE SERVER 4 THE KNOCK KNOCK PROTOCOL 5 REFERENCES Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 4. Introduction The Client The Server The Knock Knock Protocol References OUTLINE 1 INTRODUCTION 2 THE CLIENT 3 THE SERVER 4 THE KNOCK KNOCK PROTOCOL 5 REFERENCES Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 5. Introduction The Client The Server The Knock Knock Protocol References OUTLINE 1 INTRODUCTION 2 THE CLIENT 3 THE SERVER 4 THE KNOCK KNOCK PROTOCOL 5 REFERENCES Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 6. Introduction The Client The Server The Knock Knock Protocol References OUTLINE 1 INTRODUCTION 2 THE CLIENT 3 THE SERVER 4 THE KNOCK KNOCK PROTOCOL 5 REFERENCES Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 7. Introduction The Client The Server The Knock Knock Protocol References INTRODUCTION Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 8. Introduction The Client The Server The Knock Knock Protocol References THE CLIENT I /∗ ∗ Copyright ( c ) 1995, 2013, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved . ∗ ∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without ∗ modification , are permitted provided that the f o l l o w i n g conditions ∗ are met : ∗ ∗ − Redistributions of source code must r e t a i n the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer . ∗ ∗ − Redistributions in binary form must reproduce the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the ∗ documentation and / or other materials provided with the d i s t r i b u t i o n . ∗ ∗ − Neither the name of Oracle or the names of i t s ∗ c o n t r i b u t o r s may be used to endorse or promote products derived ∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission . ∗ ∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR ∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL , ∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 9. Introduction The Client The Server The Knock Knock Protocol References THE CLIENT II ∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING ∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ∗/ import java . io . ∗ ; import java . net . ∗ ; public class KnockKnockClient { public static void main ( String [ ] args ) throws IOException { i f ( args . length != 2) { System . err . p r i n t l n ( "Usage : java EchoClient <host name> <port number>" ) ; System . e x i t ( 1 ) ; } String hostName = args [ 0 ] ; int portNumber = Integer . parseInt ( args [ 1 ] ) ; try ( Socket kkSocket = new Socket ( hostName , portNumber ) ; P r i n t W r i t e r out = new P r i n t W r i t e r ( kkSocket . getOutputStream ( ) , true ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( kkSocket . getInputStream ( ) ) ) ; Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 10. Introduction The Client The Server The Knock Knock Protocol References THE CLIENT III ) { BufferedReader stdIn = new BufferedReader (new InputStreamReader ( System . in ) ) ; String fromServer ; String fromUser ; while ( ( fromServer = in . readLine ( ) ) != null ) { System . out . p r i n t l n ( " Server : " + fromServer ) ; i f ( fromServer . equals ( "Bye . " ) ) break ; fromUser = stdIn . readLine ( ) ; i f ( fromUser != null ) { System . out . p r i n t l n ( " Client : " + fromUser ) ; out . p r i n t l n ( fromUser ) ; } } } catch ( UnknownHostException e ) { System . err . p r i n t l n ( "Don ’ t know about host " + hostName ) ; System . e x i t ( 1 ) ; } catch ( IOException e ) { System . err . p r i n t l n ( " Couldn ’ t get I /O f o r the connection to " + hostName ) ; System . e x i t ( 1 ) ; } } Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 11. Introduction The Client The Server The Knock Knock Protocol References THE CLIENT IV } Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 12. Introduction The Client The Server The Knock Knock Protocol References THE SERVER I /∗ ∗ Copyright ( c ) 1995, 2014, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved . ∗ ∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without ∗ modification , are permitted provided that the f o l l o w i n g conditions ∗ are met : ∗ ∗ − Redistributions of source code must r e t a i n the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer . ∗ ∗ − Redistributions in binary form must reproduce the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the ∗ documentation and / or other materials provided with the d i s t r i b u t i o n . ∗ ∗ − Neither the name of Oracle or the names of i t s ∗ c o n t r i b u t o r s may be used to endorse or promote products derived ∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission . ∗ ∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR ∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL , ∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 13. Introduction The Client The Server The Knock Knock Protocol References THE SERVER II ∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING ∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ∗/ import java . net . ∗ ; import java . io . ∗ ; public class KnockKnockServer { public static void main ( String [ ] args ) throws IOException { i f ( args . length != 1) { System . err . p r i n t l n ( "Usage : java KnockKnockServer <port number>" ) ; System . e x i t ( 1 ) ; } int portNumber = Integer . parseInt ( args [ 0 ] ) ; try ( ServerSocket serverSocket = new ServerSocket ( portNumber ) ; Socket clientSocket = serverSocket . accept ( ) ; P r i n t W r i t e r out = new P r i n t W r i t e r ( clientSocket . getOutputStream ( ) , true ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( clientSocket . getInputStream ( ) ) ) ; Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 14. Introduction The Client The Server The Knock Knock Protocol References THE SERVER III ) { String inputLine , outputLine ; / / I n i t i a t e conversation with c l i e n t KnockKnockProtocol kkp = new KnockKnockProtocol ( ) ; outputLine = kkp . processInput ( null ) ; out . p r i n t l n ( outputLine ) ; while ( ( inputLine = in . readLine ( ) ) != null ) { outputLine = kkp . processInput ( inputLine ) ; out . p r i n t l n ( outputLine ) ; i f ( outputLine . equals ( "Bye . " ) ) break ; } } catch ( IOException e ) { System . out . p r i n t l n ( " Exception caught when t r y i n g to l i s t e n on port " + portNumber + " or l i s t e n i n g f o r a connection " ) ; System . out . p r i n t l n ( e . getMessage ( ) ) ; } } } Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 15. Introduction The Client The Server The Knock Knock Protocol References THE KNOCK KNOCK PROTOCOL I /∗ ∗ Copyright ( c ) 1995, 2008, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved . ∗ ∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without ∗ modification , are permitted provided that the f o l l o w i n g conditions ∗ are met : ∗ ∗ − Redistributions of source code must r e t a i n the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer . ∗ ∗ − Redistributions in binary form must reproduce the above copyright ∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the ∗ documentation and / or other materials provided with the d i s t r i b u t i o n . ∗ ∗ − Neither the name of Oracle or the names of i t s ∗ c o n t r i b u t o r s may be used to endorse or promote products derived ∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission . ∗ ∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS ∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR ∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR ∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL , ∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 16. Introduction The Client The Server The Knock Knock Protocol References THE KNOCK KNOCK PROTOCOL II ∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING ∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ∗/ import java . net . ∗ ; import java . io . ∗ ; public class KnockKnockProtocol { private static f i n a l int WAITING = 0; private static f i n a l int SENTKNOCKKNOCK = 1; private static f i n a l int SENTCLUE = 2; private static f i n a l int ANOTHER = 3; private static f i n a l int NUMJOKES = 5; private int state = WAITING ; private int currentJoke = 0; private String [ ] clues = { " Turnip " , " L i t t l e Old Lady " , " Atch " , "Who" , "Who" } ; private String [ ] answers = { " Turnip the heat , i t ’ s cold in here ! " , " I didn ’ t know you could yodel ! " , " Bless you ! " , " Is there an owl in here?" , " Is there an echo in here?" } ; Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 17. Introduction The Client The Server The Knock Knock Protocol References THE KNOCK KNOCK PROTOCOL III public String processInput ( String theInput ) { String theOutput = null ; i f ( state == WAITING) { theOutput = " Knock ! Knock ! " ; state = SENTKNOCKKNOCK; } else i f ( state == SENTKNOCKKNOCK) { i f ( theInput . equalsIgnoreCase ( "Who ’ s there?" ) ) { theOutput = clues [ currentJoke ] ; state = SENTCLUE; } else { theOutput = "You ’ re supposed to say "Who ’ s there ? " ! " + " Try again . Knock ! Knock ! " ; } } else i f ( state == SENTCLUE) { i f ( theInput . equalsIgnoreCase ( clues [ currentJoke ] + " who?" ) ) { theOutput = answers [ currentJoke ] + " Want another? ( y / n ) " ; state = ANOTHER; } else { theOutput = "You ’ re supposed to say " " + clues [ currentJoke ] + " who? " " + " ! Try again . Knock ! Knock ! " ; state = SENTKNOCKKNOCK; } Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 18. Introduction The Client The Server The Knock Knock Protocol References THE KNOCK KNOCK PROTOCOL IV } else i f ( state == ANOTHER) { i f ( theInput . equalsIgnoreCase ( " y " ) ) { theOutput = " Knock ! Knock ! " ; i f ( currentJoke == (NUMJOKES − 1)) currentJoke = 0; else currentJoke ++; state = SENTKNOCKKNOCK; } else { theOutput = "Bye . " ; state = WAITING ; } } return theOutput ; } } Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol
  • 19. Introduction The Client The Server The Knock Knock Protocol References REFERENCES The source code has been taken from here. This presentation has been produced with LATEX. Berlin, beetle. Muhammad Adil Raja Roaming Researchers, R . cbnaThe Knock Knock Protocol