14
Timeouts: The Missing Piece James Whorley

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

Embed Size (px)

Citation preview

Timeouts: The Missing PieceJames 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

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?

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

Solving the Problem

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

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

Making it work.

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

Solving the Problem

Prisoner’s Dilemma Applied to Socket Timeout

Making it work.

SYSTEMDone Not Done

USER

Done 1 0

Not Done 0 0

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

After only a bit of headache…

Image retrieved from: www.gitter-graphics.com

• 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?

• 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?

QuestionsFire at will…

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