views:

96

answers:

3

I am creating a non-blocking IO system for the server side of my project. The actual implementation isn't important (it is Java NIO if you care), but I feel very intimidated by the subtle issues you have to pay close attention to when programming socket communications. My knowledge is lacking in a lot of areas, so I can't even conceive of all the ways things can "go wrong"... "half-closed" connections, connections that send much more data than I would anticipate, etc.

What I am looking for is some sort of client-side tool to help test the robustness of my system by automating the process of connecting and testing for a specific behavior. Some sort of tool with different sorts of options to simulate the different ways in which connections could be open, used, and closed. Perhaps it would let me send a megabyte of gibberish at once, or try to do things that don't "make sense", all for the purposes of me being able to test random, rare things that might cause my code to break, or to fail to recognize a "broken" connection and close it.

Does a sort of tool exist? Another approach might be some Java code/unit test. Any thoughts? Thanks so much!

+2  A: 

I'd suggest looking at netcat. It gives you a very flexible way of pushing all kinds of data to a running server.

Rob H
And it is available for almost any system.
aperkins
A: 

Richard Steven's Unix Network Programming (http://www.kohala.com/start/unpv12e.html) or TCP/IP Illustrated (same site) are a must for anyone doing low-level sockets programming. Everything is in C, but the concepts are transportable.

rtenhove
+1  A: 

you can leverage your knowledge in Java writing simple unit tests that emulates random client behaviour:

  • too many data
  • too many connections
  • open and close
  • other corner cases

Pure Java tests, without native code and other tricky configuration are a huge win.

As starting point I recommend JMeter:

Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.

Take also a look at JUnitPerf website.

dfa