Top Banner
Timeouts: The Missing Piece James Whorley
14

Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Jan 02, 2016

Download

Documents

Herbert Wilcox
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Timeouts: The Missing PieceJames Whorley

Page 2: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

IMPLEMENTING TIMEOUTS IN JAVA SOCKETS

Java Socket Programming

Page 3: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Implementing Timeouts in Java SocketsSo what’s the plan?

The ProblemThe what it is and why it matters.

Sockets and Their FunctionsConnecting in 3……2……1.

ResultsSo what happened?

ReflectionWhat have we learned?

QuestionsFire at will.

Item 1

Solving the ProblemMaking it work.

Item 2

Item 3

Item 4

Item 5

Item 6

Page 4: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

The Problem

• Problem: Java Socket API Lacks Timeouts

• Proposal: • To create an adaptable platform for applicationdevelopers to control timeouts.

• To gain a level of confidence that comes from a standardized solution.

What it is and why does it matter?

Page 5: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Sockets and Their Function

• Java provides two way of connecting to a service• URL Processing• Socket Programming - Most widely used!

• Our Focus: Socket Programming• Comprised of two main classes ServerSocket and Socket• Server accepts Socket from Client• Communication ensues on specified port

Connecting in 3……2……1

Page 6: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Solving the Problem

• Planning the Solution• Game Theory Model: Prisoner’s Dilemma

• 5 Stages to Complete1. Design2. Research3. Modification4. Development5. Testing

Making it work.

Page 7: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Solving the Problem

Game Theory Model: Prisoner’s Dilemma

Making it work.

PRISONER 2Doesn’t

Talk Talks

PRISONER 1

Doesn’t Talk 1 0

Talks 0 0

Page 8: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Solving the Problem

Prisoner’s Dilemma Applied to Socket Timeout

Making it work.

SYSTEMDone Not Done

USER

Done 1 0

Not Done 0 0

Page 9: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

Solving the ProblemMaking it work.

• Determine functional requirements

Design

• Confirm design is reasonable

Research

• Tweak the design

Modification

• Create the masterpiece

Development

• Make it or break it time

Testing

Page 10: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

After only a bit of headache…

Image retrieved from: www.gitter-graphics.com

Page 11: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

• Developed working model• Default system timeout: 1 min• Default user timeout: 10 min• Can force timeout by setting both user and

system variables to done.

• Tested client/server interaction• Tested functionality against both single and

multiple connects to the server to check for erratic behavior.

ResultsSo What Happened?

Page 12: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

• Sockets are the most popular way to connect to a service with Java.

• Timeout capability not standard to sockets.

• A Prisoner’s Dilemma timeout is a great implementation to socket programming.

ReflectionWhat have we learned?

Page 13: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

QuestionsFire at will…

Page 14: Timeouts: The Missing Piece James Whorley. IMPLEMENTING TIMEOUTS IN JAVA SOCKETS Java Socket Programming.

References

• Basics in Client/Server communication in Java http://itsitrc.blogspot.com/2013/12/client-server-socket-programming-in-java.html

• Mattew Cook and Syed(shawon)M. Rahman,” Java and C/C++ language feature in terms of Network Programming,” 2005.

• Elliotte Rusty Harold,”Java Network Programming,” O’Reilly, 3rd edition, October 2004.

• Java Docs for Sockets http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html