Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java puzzle (Single threaded client server)

DZone's Guide to

Java puzzle (Single threaded client server)

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

Without creating additional threads, create a ServerSocket on a random unused port, a client Socket connecting to localhost and a server Socket.

Part 1) Send messages from client to server and back again. (This can be useful in unit tests)

Part 2) Do the same with blocking NIO.

Part 3) Benchmark how many GB/s per second you can transfer this way.

Part 4) Measure the typical and 99.99% round trip latency, and estimate how much garbage is produced.

For bonus points try the same with Async NIO2 in Java 7.

 

From http://vanillajava.blogspot.com/2011/11/java-puzzle-single-threaded-client.html

Are you using Bitbucket to accomplish your company's mission? Share your company’s mission with #Forthecode for a chance to be featured on our homepage, our social media channels, or win a free t-shirt!

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}