Info2: Exercise 03: Chatterbox
Pre-Lab
Please research the following questions before coming to the lab. Write down your answers and bring them with you for pre-lab check-in. There are many sites that will show you the code for this.
- How do you set up a connection between two computers in Java?
- Write a method to read from a connection in Java.
- Write a method to write to a connection in Java.
- How do you create concurrent threads?
Assignment
These are the required exercises for this week. Work in groups of two, each of you hands in the same report. Remember to put both your names on the report. You can continue to use BlueJ, or move to Eclipse, if you wish. We will be practicing much programming in the small this semester.
- Start your chatterbox by writing a method that listens on a port. This is your chatterbox server.
- Now write a client that writes to a port.
- Test your methods on your own machine. For now, just echo what you have read to the console to see it working. Now publish your computer name and port number on the board in the lab.
- Start chatting with a few of your neighbors! Describe what works and does not work
- Now extend your Chatterbox such that it can simultaneously receive and send messages using Java Threads.
For the bored:
- Remember that support desk application we had? Well, can you set it up so that your server listens for someone to type something, feeds it into the support desk, gets the support desk answer back and returns that to the person asking?
- Read up on Eliza and see if you can make a chatterbox “shrink” (psychiatrist).
- Create a Chat Server that can handle connections from more than one client using one Thread for each connected client.
Lab Report / What to turn in
Your report is due the day before your next lab (for exact times, please refer to moodle).
As in Informatics 1, I am more interested in process than in product, although we are now getting more interested in products as well. Your report should include any collaborators on top of the first page, summarize what you learned, and note the time you invested in this exercise. Both of you need to upload the same report in PDF format to Moodle before the deadline.
Special Questions for your report
How many lines of code did you write for each class? Record this statistic in your report.