Solved

Testing Java Sockets on Local Computer

Posted on 2008-06-24
9
359 Views
Last Modified: 2013-11-19
Hello Experts!

I am doing a homework from Distributed Programming, and thus far everything goes fine.

The only way to test my applications is to use the only computer I have as a Client, Server and a Workstation at the same time.

The problem is that I want to check how applications behave when some error happens during the transfer of big files (for example server goes down,...).

Since my client, server and workstation apps reside on the same computer they have the same IP's and the transfers are done immediately, no matter how big files are. I tried to use both localhost and my external IP address, but there is no actual trrafic! Therefore I am not able to simulate above mentioned exceptional situations.

Is there any way to simulate real traffic between two applications on the same computer. I use Java Sockets.

Thank you.
0
Comment
Question by:UrosVidojevic
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 3

Assisted Solution

by:shaz_
shaz_ earned 100 total points
Comment Utility
well.. not really.. i understand wat ure doing.. i had a similar issue while working on a p2p application... the best u can do is put a thread timeout after every so and so packets transfered.
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 200 total points
Comment Utility
I would borrow an old laptop or such and connect it UTP-UTP (cross).
The laptop might run LINUX or OSX, no worries.
To make it more critical, run a bunch of virus scans on both machines.
That helped me a lot.

;JOOP!
0
 
LVL 3

Expert Comment

by:shaz_
Comment Utility
lol love the virus scan idea sciuriware heh.. but yeh ..either its another machine or intentionally put delays on your transfer.. like i mentioned before
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Why don't you get a friend (or one of us) to run client/server?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
Never, never, never put delays intentionally!   Life isn't like that!

I've seen so many "tested" applications fail after seconds in production.

;JOOP!
0
 
LVL 3

Expert Comment

by:shaz_
Comment Utility
mm well its just to get him started since he does not seem to have another machine... ofc would never say to have an "intentionally delayed" system in production!!
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 200 total points
Comment Utility
In one of your reading loops you can introduce some random fallibility thus:


assert Math.random() < 0.95;

Unless assertions are enabled in the jvm, the lines will simply be ignored, making it easy to turn on and off
0
 
LVL 7

Author Comment

by:UrosVidojevic
Comment Utility
Thank you very much for your suggestions. My life would be much easier if this could be done on a single machine, but it seems I will have to visit university lab.

Unfortunately I can't send applications to my friends because i need to evaluate results of many test cases and try different failing scenarios. This can last for hours... and I need direct feedback.

In the meantime I will divide transfers into segments with delay, and do some stress testing as you suggested.

Once again thank you.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now